mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Format remaining files
This commit is contained in:
parent
bf47f90da6
commit
cb07debcb6
252 changed files with 5944 additions and 3744 deletions
|
@ -175,8 +175,9 @@ fn run_form_data_algorithm(
|
|||
} else {
|
||||
""
|
||||
};
|
||||
let mime: Mime = mime_str.parse().map_err(
|
||||
|_| Error::Type("Inappropriate MIME-type for Body".to_string()))?;
|
||||
let mime: Mime = mime_str
|
||||
.parse()
|
||||
.map_err(|_| Error::Type("Inappropriate MIME-type for Body".to_string()))?;
|
||||
|
||||
// TODO
|
||||
// ... Parser for Mime(TopLevel::Multipart, SubLevel::FormData, _)
|
||||
|
|
|
@ -69,7 +69,8 @@ fn main() {
|
|||
write!(
|
||||
&mut phf,
|
||||
"pub static MAP: phf::Map<&'static [u8], unsafe fn(*mut JSContext, HandleObject)> = "
|
||||
).unwrap();
|
||||
)
|
||||
.unwrap();
|
||||
map.build(&mut phf).unwrap();
|
||||
write!(&mut phf, ";\n").unwrap();
|
||||
}
|
||||
|
|
|
@ -172,7 +172,8 @@ pub fn handle_get_layout(
|
|||
paddingLeft: String::from(computed_style.PaddingLeft()),
|
||||
width: width,
|
||||
height: height,
|
||||
})).unwrap();
|
||||
}))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
fn determine_auto_margins(window: &Window, node: &Node) -> AutoMargins {
|
||||
|
|
|
@ -153,7 +153,8 @@ impl DocumentLoader {
|
|||
.send(CoreResourceMsg::Fetch(
|
||||
request,
|
||||
FetchChannels::ResponseMsg(fetch_target, Some(cancel_receiver)),
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
/// Mark an in-progress network request complete.
|
||||
|
|
|
@ -37,17 +37,20 @@ impl AnalyserNode {
|
|||
context: &BaseAudioContext,
|
||||
options: &AnalyserOptions,
|
||||
) -> Fallible<(AnalyserNode, IpcReceiver<Block>)> {
|
||||
let node_options = options.parent
|
||||
.unwrap_or(2, ChannelCountMode::Max,
|
||||
ChannelInterpretation::Speakers);
|
||||
let node_options =
|
||||
options
|
||||
.parent
|
||||
.unwrap_or(2, ChannelCountMode::Max, ChannelInterpretation::Speakers);
|
||||
|
||||
if options.fftSize > 32768 || options.fftSize < 32 ||
|
||||
(options.fftSize & (options.fftSize - 1) != 0) {
|
||||
return Err(Error::IndexSize)
|
||||
if options.fftSize > 32768 ||
|
||||
options.fftSize < 32 ||
|
||||
(options.fftSize & (options.fftSize - 1) != 0)
|
||||
{
|
||||
return Err(Error::IndexSize);
|
||||
}
|
||||
|
||||
if *options.maxDecibels <= *options.minDecibels {
|
||||
return Err(Error::IndexSize)
|
||||
return Err(Error::IndexSize);
|
||||
}
|
||||
|
||||
if *options.smoothingTimeConstant < 0. || *options.smoothingTimeConstant > 1. {
|
||||
|
@ -67,14 +70,19 @@ impl AnalyserNode {
|
|||
1, // outputs
|
||||
)?;
|
||||
|
||||
|
||||
let engine = AnalysisEngine::new(options.fftSize as usize,
|
||||
*options.smoothingTimeConstant,
|
||||
*options.minDecibels, *options.maxDecibels);
|
||||
Ok((AnalyserNode {
|
||||
node,
|
||||
engine: DomRefCell::new(engine)
|
||||
}, rcv))
|
||||
let engine = AnalysisEngine::new(
|
||||
options.fftSize as usize,
|
||||
*options.smoothingTimeConstant,
|
||||
*options.minDecibels,
|
||||
*options.maxDecibels,
|
||||
);
|
||||
Ok((
|
||||
AnalyserNode {
|
||||
node,
|
||||
engine: DomRefCell::new(engine),
|
||||
},
|
||||
rcv,
|
||||
))
|
||||
}
|
||||
|
||||
#[allow(unrooted_must_root)]
|
||||
|
@ -89,13 +97,19 @@ impl AnalyserNode {
|
|||
let canceller = window.task_canceller(TaskSourceName::DOMManipulation);
|
||||
let this = Trusted::new(&*object);
|
||||
|
||||
ROUTER.add_route(recv.to_opaque(), Box::new(move |block| {
|
||||
let this = this.clone();
|
||||
let _ = source.queue_with_canceller(task!(append_analysis_block: move || {
|
||||
ROUTER.add_route(
|
||||
recv.to_opaque(),
|
||||
Box::new(move |block| {
|
||||
let this = this.clone();
|
||||
let _ = source.queue_with_canceller(
|
||||
task!(append_analysis_block: move || {
|
||||
let this = this.root();
|
||||
this.push_block(block.to().unwrap())
|
||||
}), &canceller);
|
||||
}));
|
||||
}),
|
||||
&canceller,
|
||||
);
|
||||
}),
|
||||
);
|
||||
Ok(object)
|
||||
}
|
||||
|
||||
|
@ -130,7 +144,6 @@ impl AnalyserNodeMethods for AnalyserNode {
|
|||
// run whilst we're writing to it
|
||||
let dest = unsafe { array.as_mut_slice() };
|
||||
self.engine.borrow_mut().fill_byte_frequency_data(dest);
|
||||
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
|
@ -140,7 +153,6 @@ impl AnalyserNodeMethods for AnalyserNode {
|
|||
// run whilst we're writing to it
|
||||
let dest = unsafe { array.as_mut_slice() };
|
||||
self.engine.borrow().fill_time_domain_data(dest);
|
||||
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
|
@ -150,14 +162,12 @@ impl AnalyserNodeMethods for AnalyserNode {
|
|||
// run whilst we're writing to it
|
||||
let dest = unsafe { array.as_mut_slice() };
|
||||
self.engine.borrow().fill_byte_time_domain_data(dest);
|
||||
|
||||
}
|
||||
|
||||
/// https://webaudio.github.io/web-audio-api/#dom-analysernode-fftsize
|
||||
fn SetFftSize(&self, value: u32) -> Fallible<()> {
|
||||
if value > 32768 || value < 32 ||
|
||||
(value & (value - 1) != 0) {
|
||||
return Err(Error::IndexSize)
|
||||
if value > 32768 || value < 32 || (value & (value - 1) != 0) {
|
||||
return Err(Error::IndexSize);
|
||||
}
|
||||
self.engine.borrow_mut().set_fft_size(value as usize);
|
||||
Ok(())
|
||||
|
@ -181,7 +191,7 @@ impl AnalyserNodeMethods for AnalyserNode {
|
|||
/// https://webaudio.github.io/web-audio-api/#dom-analysernode-mindecibels
|
||||
fn SetMinDecibels(&self, value: Finite<f64>) -> Fallible<()> {
|
||||
if *value >= self.engine.borrow().get_max_decibels() {
|
||||
return Err(Error::IndexSize)
|
||||
return Err(Error::IndexSize);
|
||||
}
|
||||
self.engine.borrow_mut().set_min_decibels(*value);
|
||||
Ok(())
|
||||
|
@ -195,7 +205,7 @@ impl AnalyserNodeMethods for AnalyserNode {
|
|||
/// https://webaudio.github.io/web-audio-api/#dom-analysernode-maxdecibels
|
||||
fn SetMaxDecibels(&self, value: Finite<f64>) -> Fallible<()> {
|
||||
if *value <= self.engine.borrow().get_min_decibels() {
|
||||
return Err(Error::IndexSize)
|
||||
return Err(Error::IndexSize);
|
||||
}
|
||||
self.engine.borrow_mut().set_max_decibels(*value);
|
||||
Ok(())
|
||||
|
@ -209,10 +219,9 @@ impl AnalyserNodeMethods for AnalyserNode {
|
|||
/// https://webaudio.github.io/web-audio-api/#dom-analysernode-smoothingtimeconstant
|
||||
fn SetSmoothingTimeConstant(&self, value: Finite<f64>) -> Fallible<()> {
|
||||
if *value < 0. || *value > 1. {
|
||||
return Err(Error::IndexSize)
|
||||
return Err(Error::IndexSize);
|
||||
}
|
||||
self.engine.borrow_mut().set_smoothing_constant(*value);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -110,10 +110,8 @@ impl AudioBuffer {
|
|||
// Initialize the underlying channels data with initial data provided by
|
||||
// the user or silence otherwise.
|
||||
fn set_initial_data(&self, initial_data: Option<&[Vec<f32>]>) {
|
||||
let mut channels = ServoMediaAudioBuffer::new(
|
||||
self.number_of_channels as u8,
|
||||
self.length as usize,
|
||||
);
|
||||
let mut channels =
|
||||
ServoMediaAudioBuffer::new(self.number_of_channels as u8, self.length as usize);
|
||||
for channel in 0..self.number_of_channels {
|
||||
channels.buffers[channel as usize] = match initial_data {
|
||||
Some(data) => data[channel as usize].clone(),
|
||||
|
@ -143,7 +141,8 @@ impl AudioBuffer {
|
|||
cx,
|
||||
CreateWith::Slice(&shared_channels.buffers[i]),
|
||||
array.handle_mut(),
|
||||
).is_err()
|
||||
)
|
||||
.is_err()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -159,10 +158,8 @@ impl AudioBuffer {
|
|||
// https://webaudio.github.io/web-audio-api/#acquire-the-content
|
||||
#[allow(unsafe_code)]
|
||||
fn acquire_contents(&self) -> Option<ServoMediaAudioBuffer> {
|
||||
let mut result = ServoMediaAudioBuffer::new(
|
||||
self.number_of_channels as u8,
|
||||
self.length as usize,
|
||||
);
|
||||
let mut result =
|
||||
ServoMediaAudioBuffer::new(self.number_of_channels as u8, self.length as usize);
|
||||
let cx = self.global().get_cx();
|
||||
for (i, channel) in self.js_channels.borrow_mut().iter().enumerate() {
|
||||
// Step 1.
|
||||
|
@ -203,7 +200,7 @@ impl AudioBuffer {
|
|||
*self.shared_channels.borrow_mut() = channels;
|
||||
}
|
||||
}
|
||||
return self.shared_channels.borrow()
|
||||
return self.shared_channels.borrow();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -324,7 +321,8 @@ impl AudioBufferMethods for AudioBuffer {
|
|||
let js_channel_data = unsafe { js_channel.as_mut_slice() };
|
||||
let (_, js_channel_data) = js_channel_data.split_at_mut(start_in_channel as usize);
|
||||
unsafe {
|
||||
js_channel_data[0..bytes_to_copy].copy_from_slice(&source.as_slice()[0..bytes_to_copy])
|
||||
js_channel_data[0..bytes_to_copy]
|
||||
.copy_from_slice(&source.as_slice()[0..bytes_to_copy])
|
||||
};
|
||||
} else {
|
||||
return Err(Error::IndexSize);
|
||||
|
|
|
@ -348,7 +348,11 @@ impl BaseAudioContextMethods for BaseAudioContext {
|
|||
|
||||
/// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createbiquadfilter
|
||||
fn CreateBiquadFilter(&self) -> Fallible<DomRoot<BiquadFilterNode>> {
|
||||
BiquadFilterNode::new(&self.global().as_window(), &self, &BiquadFilterOptions::empty())
|
||||
BiquadFilterNode::new(
|
||||
&self.global().as_window(),
|
||||
&self,
|
||||
&BiquadFilterOptions::empty(),
|
||||
)
|
||||
}
|
||||
|
||||
/// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createchannelmerger
|
||||
|
@ -432,10 +436,12 @@ impl BaseAudioContextMethods for BaseAudioContext {
|
|||
.lock()
|
||||
.unwrap()
|
||||
.resize(channel_count as usize, Vec::new());
|
||||
}).progress(move |buffer, channel| {
|
||||
})
|
||||
.progress(move |buffer, channel| {
|
||||
let mut decoded_audio = decoded_audio_.lock().unwrap();
|
||||
decoded_audio[(channel - 1) as usize].extend_from_slice((*buffer).as_ref());
|
||||
}).eos(move || {
|
||||
})
|
||||
.eos(move || {
|
||||
let _ = task_source.queue_with_canceller(
|
||||
task!(audio_decode_eos: move || {
|
||||
let this = this.root();
|
||||
|
@ -461,7 +467,8 @@ impl BaseAudioContextMethods for BaseAudioContext {
|
|||
}),
|
||||
&canceller,
|
||||
);
|
||||
}).error(move |error| {
|
||||
})
|
||||
.error(move |error| {
|
||||
let _ = task_source_.queue_with_canceller(
|
||||
task!(audio_decode_eos: move || {
|
||||
let this = this_.root();
|
||||
|
@ -478,7 +485,8 @@ impl BaseAudioContextMethods for BaseAudioContext {
|
|||
}),
|
||||
&canceller_,
|
||||
);
|
||||
}).build();
|
||||
})
|
||||
.build();
|
||||
self.audio_context_impl
|
||||
.decode_audio_data(audio_data, callbacks);
|
||||
} else {
|
||||
|
|
|
@ -94,7 +94,8 @@ pub fn entry_global() -> DomRoot<GlobalScope> {
|
|||
.rev()
|
||||
.find(|entry| entry.kind == StackEntryKind::Entry)
|
||||
.map(|entry| DomRoot::from_ref(&*entry.global))
|
||||
}).unwrap()
|
||||
})
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
/// RAII struct that pushes and pops entries from the script settings stack.
|
||||
|
|
|
@ -457,7 +457,7 @@ unsafe_no_jsmanaged_fields!(AudioBuffer);
|
|||
unsafe_no_jsmanaged_fields!(AudioContext<Backend>);
|
||||
unsafe_no_jsmanaged_fields!(NodeId);
|
||||
unsafe_no_jsmanaged_fields!(AnalysisEngine, DistanceModel, PanningModel, ParamType);
|
||||
unsafe_no_jsmanaged_fields!(Player<Error=ServoMediaError>);
|
||||
unsafe_no_jsmanaged_fields!(Player<Error = ServoMediaError>);
|
||||
unsafe_no_jsmanaged_fields!(Mutex<MediaFrameRenderer>);
|
||||
unsafe_no_jsmanaged_fields!(RenderApiSender);
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ pub fn get_array_index_from_id(_cx: *mut JSContext, id: HandleId) -> Option<u32>
|
|||
if s > 'a' && s < 'z' {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
let i = 0;
|
||||
let str = AtomToLinearString(JSID_TO_ATOM(id));
|
||||
return if StringIsArray(str, &mut i) != 0 { i } else { -1 }
|
||||
|
|
|
@ -39,9 +39,10 @@ impl BiquadFilterNode {
|
|||
context: &BaseAudioContext,
|
||||
options: &BiquadFilterOptions,
|
||||
) -> Fallible<BiquadFilterNode> {
|
||||
let node_options = options.parent
|
||||
.unwrap_or(2, ChannelCountMode::Max,
|
||||
ChannelInterpretation::Speakers);
|
||||
let node_options =
|
||||
options
|
||||
.parent
|
||||
.unwrap_or(2, ChannelCountMode::Max, ChannelInterpretation::Speakers);
|
||||
let filter = Cell::new(options.type_);
|
||||
let options = options.into();
|
||||
let node = AudioNode::new_inherited(
|
||||
|
@ -57,9 +58,9 @@ impl BiquadFilterNode {
|
|||
node.node_id(),
|
||||
ParamType::Gain,
|
||||
AutomationRate::A_rate,
|
||||
options.gain, // default value
|
||||
f32::MIN, // min value
|
||||
f32::MAX, // max value
|
||||
options.gain, // default value
|
||||
f32::MIN, // min value
|
||||
f32::MAX, // max value
|
||||
);
|
||||
let q = AudioParam::new(
|
||||
window,
|
||||
|
@ -67,9 +68,9 @@ impl BiquadFilterNode {
|
|||
node.node_id(),
|
||||
ParamType::Q,
|
||||
AutomationRate::A_rate,
|
||||
options.q, // default value
|
||||
f32::MIN, // min value
|
||||
f32::MAX, // max value
|
||||
options.q, // default value
|
||||
f32::MIN, // min value
|
||||
f32::MAX, // max value
|
||||
);
|
||||
let frequency = AudioParam::new(
|
||||
window,
|
||||
|
@ -77,9 +78,9 @@ impl BiquadFilterNode {
|
|||
node.node_id(),
|
||||
ParamType::Frequency,
|
||||
AutomationRate::A_rate,
|
||||
options.frequency, // default value
|
||||
f32::MIN, // min value
|
||||
f32::MAX, // max value
|
||||
options.frequency, // default value
|
||||
f32::MIN, // min value
|
||||
f32::MAX, // max value
|
||||
);
|
||||
let detune = AudioParam::new(
|
||||
window,
|
||||
|
@ -87,9 +88,9 @@ impl BiquadFilterNode {
|
|||
node.node_id(),
|
||||
ParamType::Detune,
|
||||
AutomationRate::A_rate,
|
||||
options.detune, // default value
|
||||
f32::MIN, // min value
|
||||
f32::MAX, // max value
|
||||
options.detune, // default value
|
||||
f32::MIN, // min value
|
||||
f32::MAX, // max value
|
||||
);
|
||||
Ok(BiquadFilterNode {
|
||||
node,
|
||||
|
@ -108,7 +109,11 @@ impl BiquadFilterNode {
|
|||
options: &BiquadFilterOptions,
|
||||
) -> Fallible<DomRoot<BiquadFilterNode>> {
|
||||
let node = BiquadFilterNode::new_inherited(window, context, options)?;
|
||||
Ok(reflect_dom_object(Box::new(node), window, BiquadFilterNodeBinding::Wrap))
|
||||
Ok(reflect_dom_object(
|
||||
Box::new(node),
|
||||
window,
|
||||
BiquadFilterNodeBinding::Wrap,
|
||||
))
|
||||
}
|
||||
|
||||
pub fn Constructor(
|
||||
|
@ -149,10 +154,9 @@ impl BiquadFilterNodeMethods for BiquadFilterNode {
|
|||
// https://webaudio.github.io/web-audio-api/#dom-biquadfilternode-type
|
||||
fn SetType(&self, filter: BiquadFilterType) {
|
||||
self.filter.set(filter);
|
||||
self.node
|
||||
.message(AudioNodeMessage::BiquadFilterNode(
|
||||
BiquadFilterNodeMessage::SetFilterType(filter.into()),
|
||||
));
|
||||
self.node.message(AudioNodeMessage::BiquadFilterNode(
|
||||
BiquadFilterNodeMessage::SetFilterType(filter.into()),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,7 +167,7 @@ impl<'a> From<&'a BiquadFilterOptions> for BiquadFilterNodeOptions {
|
|||
q: *options.Q,
|
||||
frequency: *options.frequency,
|
||||
detune: *options.detune,
|
||||
filter: options.type_.into()
|
||||
filter: options.type_.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -334,7 +334,8 @@ where
|
|||
single,
|
||||
child_type,
|
||||
sender,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -694,7 +695,8 @@ impl PermissionAlgorithm for Bluetooth {
|
|||
device_id.clone(),
|
||||
BluetoothScanfilterSequence::new(scan_filters),
|
||||
sender,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
|
||||
match receiver.recv().unwrap() {
|
||||
Ok(true) => (),
|
||||
|
|
|
@ -152,7 +152,8 @@ impl BluetoothDevice {
|
|||
.send(BluetoothRequest::IsRepresentedDeviceNull(
|
||||
self.Id().to_string(),
|
||||
sender,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
receiver.recv().unwrap()
|
||||
}
|
||||
|
||||
|
@ -242,7 +243,8 @@ impl BluetoothDevice {
|
|||
.send(BluetoothRequest::GATTServerDisconnect(
|
||||
String::from(self.Id()),
|
||||
sender,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
receiver.recv().unwrap().map_err(Error::from)
|
||||
}
|
||||
}
|
||||
|
@ -286,7 +288,8 @@ impl BluetoothDeviceMethods for BluetoothDevice {
|
|||
.send(BluetoothRequest::WatchAdvertisements(
|
||||
String::from(self.Id()),
|
||||
sender,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
return p;
|
||||
}
|
||||
|
||||
|
|
|
@ -216,7 +216,8 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
|
|||
self.get_instance_id(),
|
||||
vec,
|
||||
sender,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -253,7 +254,8 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
|
|||
self.get_instance_id(),
|
||||
true,
|
||||
sender,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -272,7 +274,8 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
|
|||
self.get_instance_id(),
|
||||
false,
|
||||
sender,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
return p;
|
||||
}
|
||||
|
||||
|
|
|
@ -166,7 +166,8 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
|
|||
self.get_instance_id(),
|
||||
vec,
|
||||
sender,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,8 @@ impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer {
|
|||
.send(BluetoothRequest::GATTServerConnect(
|
||||
String::from(self.Device().Id()),
|
||||
sender,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
// Step 5: return promise.
|
||||
return p;
|
||||
}
|
||||
|
|
|
@ -266,7 +266,7 @@ impl CanvasRenderingContext2D {
|
|||
CanvasImageSource::HTMLCanvasElement(canvas) => canvas.origin_is_clean(),
|
||||
CanvasImageSource::HTMLImageElement(image) => {
|
||||
image.same_origin(GlobalScope::entry().origin())
|
||||
}
|
||||
},
|
||||
CanvasImageSource::CSSStyleValue(_) => true,
|
||||
}
|
||||
}
|
||||
|
@ -403,8 +403,7 @@ impl CanvasRenderingContext2D {
|
|||
dh: Option<f64>,
|
||||
) -> ErrorResult {
|
||||
debug!("Fetching image {}.", url);
|
||||
let (mut image_data, image_size) =
|
||||
self.fetch_image_data(url).ok_or(Error::InvalidState)?;
|
||||
let (mut image_data, image_size) = self.fetch_image_data(url).ok_or(Error::InvalidState)?;
|
||||
pixels::premultiply_inplace(&mut image_data);
|
||||
let image_size = image_size.to_f64();
|
||||
|
||||
|
@ -558,7 +557,10 @@ impl CanvasRenderingContext2D {
|
|||
|
||||
// FIXME(nox): This is probably wrong when this is a context for an
|
||||
// offscreen canvas.
|
||||
let canvas_size = self.canvas.as_ref().map_or(Size2D::zero(), |c| c.get_size());
|
||||
let canvas_size = self
|
||||
.canvas
|
||||
.as_ref()
|
||||
.map_or(Size2D::zero(), |c| c.get_size());
|
||||
assert!(Rect::from_size(canvas_size).contains_rect(&rect));
|
||||
|
||||
let (sender, receiver) = ipc::bytes_channel().unwrap();
|
||||
|
@ -1144,7 +1146,10 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
let (origin, size) = adjust_size_sign(Point2D::new(sx, sy), Size2D::new(sw, sh));
|
||||
// FIXME(nox): This is probably wrong when this is a context for an
|
||||
// offscreen canvas.
|
||||
let canvas_size = self.canvas.as_ref().map_or(Size2D::zero(), |c| c.get_size());
|
||||
let canvas_size = self
|
||||
.canvas
|
||||
.as_ref()
|
||||
.map_or(Size2D::zero(), |c| c.get_size());
|
||||
let read_rect = match pixels::clip(origin, size, canvas_size) {
|
||||
Some(rect) => rect,
|
||||
None => {
|
||||
|
@ -1153,12 +1158,25 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
},
|
||||
};
|
||||
|
||||
ImageData::new(&self.global(), size.width, size.height, Some(self.get_rect(read_rect)))
|
||||
ImageData::new(
|
||||
&self.global(),
|
||||
size.width,
|
||||
size.height,
|
||||
Some(self.get_rect(read_rect)),
|
||||
)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-putimagedata
|
||||
fn PutImageData(&self, imagedata: &ImageData, dx: i32, dy: i32) {
|
||||
self.PutImageData_(imagedata, dx, dy, 0, 0, imagedata.Width() as i32, imagedata.Height() as i32)
|
||||
self.PutImageData_(
|
||||
imagedata,
|
||||
dx,
|
||||
dy,
|
||||
0,
|
||||
0,
|
||||
imagedata.Width() as i32,
|
||||
imagedata.Height() as i32,
|
||||
)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-putimagedata
|
||||
|
@ -1176,7 +1194,6 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
// FIXME(nox): There are many arithmetic operations here that can
|
||||
// overflow or underflow, this should probably be audited.
|
||||
|
||||
|
||||
let imagedata_size = Size2D::new(imagedata.Width(), imagedata.Height());
|
||||
if imagedata_size.area() == 0 {
|
||||
return;
|
||||
|
@ -1190,7 +1207,10 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
|
||||
// FIXME(nox): This is probably wrong when this is a context for an
|
||||
// offscreen canvas.
|
||||
let canvas_size = self.canvas.as_ref().map_or(Size2D::zero(), |c| c.get_size());
|
||||
let canvas_size = self
|
||||
.canvas
|
||||
.as_ref()
|
||||
.map_or(Size2D::zero(), |c| c.get_size());
|
||||
|
||||
// Steps 3-6.
|
||||
let (src_origin, src_size) = adjust_size_sign(
|
||||
|
@ -1214,9 +1234,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
|
||||
// Step 7.
|
||||
let (sender, receiver) = ipc::bytes_channel().unwrap();
|
||||
let pixels = unsafe {
|
||||
&imagedata.get_rect(Rect::new(src_rect.origin, dst_rect.size))
|
||||
};
|
||||
let pixels = unsafe { &imagedata.get_rect(Rect::new(src_rect.origin, dst_rect.size)) };
|
||||
self.send_canvas_2d_msg(Canvas2dMsg::PutImageData(dst_rect, receiver));
|
||||
sender.send(pixels).unwrap();
|
||||
self.mark_as_dirty();
|
||||
|
|
|
@ -157,7 +157,8 @@ impl CSSStyleOwner {
|
|||
.style_stylesheet()
|
||||
.contents
|
||||
.url_data
|
||||
.read()).clone(),
|
||||
.read())
|
||||
.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,14 +82,13 @@ impl CSSSupportsRule {
|
|||
None,
|
||||
);
|
||||
let enabled = {
|
||||
let namespaces =
|
||||
self
|
||||
.cssconditionrule
|
||||
.parent_stylesheet()
|
||||
.style_stylesheet()
|
||||
.contents
|
||||
.namespaces
|
||||
.read();
|
||||
let namespaces = self
|
||||
.cssconditionrule
|
||||
.parent_stylesheet()
|
||||
.style_stylesheet()
|
||||
.contents
|
||||
.namespaces
|
||||
.read();
|
||||
cond.eval(&context, &namespaces)
|
||||
};
|
||||
let mut guard = self.cssconditionrule.shared_lock().write();
|
||||
|
|
|
@ -97,7 +97,8 @@ impl CustomElementRegistry {
|
|||
// Step 4-5
|
||||
definition.local_name == *local_name &&
|
||||
(definition.name == *local_name || Some(&definition.name) == is)
|
||||
}).cloned()
|
||||
})
|
||||
.cloned()
|
||||
}
|
||||
|
||||
pub fn lookup_definition_by_constructor(
|
||||
|
|
|
@ -318,7 +318,8 @@ impl DedicatedWorkerGlobalScope {
|
|||
Box::new(SimpleWorkerErrorHandler::new(worker)),
|
||||
pipeline_id,
|
||||
TaskSourceName::DOMManipulation,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
return;
|
||||
},
|
||||
Ok((metadata, bytes)) => (metadata, bytes),
|
||||
|
@ -391,7 +392,8 @@ impl DedicatedWorkerGlobalScope {
|
|||
parent_sender,
|
||||
CommonScriptMsg::CollectReports,
|
||||
);
|
||||
}).expect("Thread spawning failed");
|
||||
})
|
||||
.expect("Thread spawning failed");
|
||||
}
|
||||
|
||||
pub fn script_chan(&self) -> Box<ScriptChan + Send> {
|
||||
|
@ -495,7 +497,8 @@ impl DedicatedWorkerGlobalScope {
|
|||
task,
|
||||
Some(pipeline_id),
|
||||
TaskSourceName::DOMManipulation,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -526,7 +529,8 @@ impl DedicatedWorkerGlobalScopeMethods for DedicatedWorkerGlobalScope {
|
|||
task,
|
||||
Some(pipeline_id),
|
||||
TaskSourceName::DOMManipulation,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -539,7 +539,8 @@ impl Document {
|
|||
);
|
||||
}),
|
||||
self.window.upcast(),
|
||||
).unwrap();
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
} else {
|
||||
self.window().suspend();
|
||||
|
@ -1904,7 +1905,8 @@ impl Document {
|
|||
}
|
||||
}),
|
||||
self.window.upcast(),
|
||||
).unwrap();
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// Step 8.
|
||||
let document = Trusted::new(self);
|
||||
|
@ -1938,7 +1940,8 @@ impl Document {
|
|||
);
|
||||
}),
|
||||
self.window.upcast(),
|
||||
).unwrap();
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
// Step 9.
|
||||
|
@ -2780,14 +2783,16 @@ impl Document {
|
|||
owner
|
||||
.upcast::<Node>()
|
||||
.is_before(sheet_in_doc.owner.upcast())
|
||||
}).cloned();
|
||||
})
|
||||
.cloned();
|
||||
|
||||
self.window()
|
||||
.layout_chan()
|
||||
.send(Msg::AddStylesheet(
|
||||
sheet.clone(),
|
||||
insertion_point.as_ref().map(|s| s.sheet.clone()),
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
|
||||
let sheet = StyleSheetInDocument {
|
||||
sheet,
|
||||
|
@ -3621,7 +3626,8 @@ impl DocumentMethods for Document {
|
|||
.child_elements()
|
||||
.find(|node| {
|
||||
node.namespace() == &ns!(svg) && node.local_name() == &local_name!("title")
|
||||
}).map(DomRoot::upcast::<Node>)
|
||||
})
|
||||
.map(DomRoot::upcast::<Node>)
|
||||
} else {
|
||||
// Step 2.
|
||||
root.upcast::<Node>()
|
||||
|
@ -3726,7 +3732,8 @@ impl DocumentMethods for Document {
|
|||
HTMLElementTypeId::HTMLFrameSetElement,
|
||||
)) => true,
|
||||
_ => false,
|
||||
}).map(|node| DomRoot::downcast(node).unwrap())
|
||||
})
|
||||
.map(|node| DomRoot::downcast(node).unwrap())
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -3947,16 +3954,18 @@ impl DocumentMethods for Document {
|
|||
return Err(Error::Security);
|
||||
}
|
||||
|
||||
let cookies = if let Some(cookie) = cookie_rs::Cookie::parse(cookie.to_string()).ok().map(Serde) {
|
||||
vec![cookie]
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
let cookies =
|
||||
if let Some(cookie) = cookie_rs::Cookie::parse(cookie.to_string()).ok().map(Serde) {
|
||||
vec![cookie]
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
|
||||
let _ = self.window
|
||||
.upcast::<GlobalScope>()
|
||||
.resource_threads()
|
||||
.send(SetCookiesForUrl(self.url(), cookies, NonHTTP));
|
||||
let _ = self
|
||||
.window
|
||||
.upcast::<GlobalScope>()
|
||||
.resource_threads()
|
||||
.send(SetCookiesForUrl(self.url(), cookies, NonHTTP));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -4158,7 +4167,8 @@ impl DocumentMethods for Document {
|
|||
node::from_untrusted_node_address(js_runtime, untrusted_node_address)
|
||||
};
|
||||
DomRoot::downcast::<Element>(node)
|
||||
}).collect();
|
||||
})
|
||||
.collect();
|
||||
|
||||
// Step 4
|
||||
if let Some(root_element) = self.GetDocumentElement() {
|
||||
|
@ -4172,7 +4182,11 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-document-open
|
||||
fn Open(&self, _unused1: Option<DOMString>, _unused2: Option<DOMString>) -> Fallible<DomRoot<Document>> {
|
||||
fn Open(
|
||||
&self,
|
||||
_unused1: Option<DOMString>,
|
||||
_unused2: Option<DOMString>,
|
||||
) -> Fallible<DomRoot<Document>> {
|
||||
// Step 1
|
||||
if !self.is_html_document() {
|
||||
return Err(Error::InvalidState);
|
||||
|
@ -4266,12 +4280,19 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-document-open-window
|
||||
fn Open_(&self, url: DOMString, target: DOMString, features: DOMString) -> Fallible<DomRoot<WindowProxy>> {
|
||||
fn Open_(
|
||||
&self,
|
||||
url: DOMString,
|
||||
target: DOMString,
|
||||
features: DOMString,
|
||||
) -> Fallible<DomRoot<WindowProxy>> {
|
||||
// WhatWG spec states this should always return a WindowProxy, but the spec for WindowProxy.open states
|
||||
// it optionally returns a WindowProxy. Assume an error if window.open returns none.
|
||||
// See https://github.com/whatwg/html/issues/4091
|
||||
let context = self.browsing_context().ok_or(Error::InvalidAccess)?;
|
||||
context.open(url, target, features).ok_or(Error::InvalidAccess)
|
||||
context
|
||||
.open(url, target, features)
|
||||
.ok_or(Error::InvalidAccess)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-document-write
|
||||
|
@ -4297,7 +4318,9 @@ impl DocumentMethods for Document {
|
|||
// Either there is no parser, which means the parsing ended;
|
||||
// or script nesting level is 0, which means the method was
|
||||
// called from outside a parser-executed script.
|
||||
if self.is_prompting_or_unloading() || self.ignore_destructive_writes_counter.get() > 0 {
|
||||
if self.is_prompting_or_unloading() ||
|
||||
self.ignore_destructive_writes_counter.get() > 0
|
||||
{
|
||||
// Step 4.
|
||||
return Ok(());
|
||||
}
|
||||
|
|
|
@ -295,7 +295,8 @@ impl DOMMatrixMethods for DOMMatrix {
|
|||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-multiplyself
|
||||
fn MultiplySelf(&self, other: &DOMMatrixInit) -> Fallible<DomRoot<DOMMatrix>> {
|
||||
// Steps 1-3.
|
||||
self.upcast::<DOMMatrixReadOnly>().multiply_self(other)
|
||||
self.upcast::<DOMMatrixReadOnly>()
|
||||
.multiply_self(other)
|
||||
// Step 4.
|
||||
.and(Ok(DomRoot::from_ref(&self)))
|
||||
}
|
||||
|
@ -303,7 +304,8 @@ impl DOMMatrixMethods for DOMMatrix {
|
|||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-premultiplyself
|
||||
fn PreMultiplySelf(&self, other: &DOMMatrixInit) -> Fallible<DomRoot<DOMMatrix>> {
|
||||
// Steps 1-3.
|
||||
self.upcast::<DOMMatrixReadOnly>().pre_multiply_self(other)
|
||||
self.upcast::<DOMMatrixReadOnly>()
|
||||
.pre_multiply_self(other)
|
||||
// Step 4.
|
||||
.and(Ok(DomRoot::from_ref(&self)))
|
||||
}
|
||||
|
|
|
@ -456,7 +456,8 @@ pub unsafe fn get_attr_for_layout<'a>(
|
|||
.find(|attr| {
|
||||
let attr = attr.to_layout();
|
||||
*name == attr.local_name_atom_forever() && (*attr.unsafe_get()).namespace() == namespace
|
||||
}).map(|attr| attr.to_layout())
|
||||
})
|
||||
.map(|attr| attr.to_layout())
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
|
@ -491,7 +492,8 @@ impl RawLayoutElementHelpers for Element {
|
|||
} else {
|
||||
None
|
||||
}
|
||||
}).collect()
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2014,7 +2016,8 @@ impl ElementMethods for Element {
|
|||
rect.size.width.to_f64_px(),
|
||||
rect.size.height.to_f64_px(),
|
||||
)
|
||||
}).collect()
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-element-getboundingclientrect
|
||||
|
@ -2766,9 +2769,7 @@ impl<'a> SelectorsElement for DomRoot<Element> {
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
fn opaque(&self) -> ::selectors::OpaqueElement {
|
||||
::selectors::OpaqueElement::new(unsafe {
|
||||
&*self.reflector().get_jsobject().get()
|
||||
})
|
||||
::selectors::OpaqueElement::new(unsafe { &*self.reflector().get_jsobject().get() })
|
||||
}
|
||||
|
||||
fn parent_element(&self) -> Option<DomRoot<Element>> {
|
||||
|
@ -3102,7 +3103,8 @@ impl Element {
|
|||
})
|
||||
// TODO: Check meta tags for a pragma-set default language
|
||||
// TODO: Check HTTP Content-Language header
|
||||
}).next()
|
||||
})
|
||||
.next()
|
||||
.unwrap_or(String::new())
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@ use std::str::{Chars, FromStr};
|
|||
use std::sync::{Arc, Mutex};
|
||||
use utf8;
|
||||
|
||||
|
||||
const DEFAULT_RECONNECTION_TIME: u64 = 5000;
|
||||
|
||||
#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)]
|
||||
|
@ -179,8 +178,10 @@ impl EventSourceContext {
|
|||
self.data.push('\n');
|
||||
},
|
||||
"id" => mem::swap(&mut self.last_event_id, &mut self.value),
|
||||
"retry" => if let Ok(time) = u64::from_str(&self.value) {
|
||||
self.event_source.root().reconnection_time.set(time);
|
||||
"retry" => {
|
||||
if let Ok(time) = u64::from_str(&self.value) {
|
||||
self.event_source.root().reconnection_time.set(time);
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
|
@ -339,13 +340,15 @@ impl FetchResponseListener for EventSourceContext {
|
|||
match meta.content_type {
|
||||
None => self.fail_the_connection(),
|
||||
Some(ct) => {
|
||||
if <ContentType as Into<Mime>>::into(ct.into_inner()) == mime::TEXT_EVENT_STREAM {
|
||||
if <ContentType as Into<Mime>>::into(ct.into_inner()) ==
|
||||
mime::TEXT_EVENT_STREAM
|
||||
{
|
||||
self.origin = meta.final_url.origin().ascii_serialization();
|
||||
self.announce_the_connection();
|
||||
} else {
|
||||
self.fail_the_connection()
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
Err(_) => {
|
||||
|
@ -503,7 +506,10 @@ impl EventSource {
|
|||
};
|
||||
// Step 10
|
||||
// TODO(eijebong): Replace once typed headers allow it
|
||||
request.headers.insert(header::ACCEPT, HeaderValue::from_static("text/event-stream"));
|
||||
request.headers.insert(
|
||||
header::ACCEPT,
|
||||
HeaderValue::from_static("text/event-stream"),
|
||||
);
|
||||
// Step 11
|
||||
request.cache_mode = CacheMode::NoStore;
|
||||
// Step 12
|
||||
|
@ -543,7 +549,8 @@ impl EventSource {
|
|||
.send(CoreResourceMsg::Fetch(
|
||||
request,
|
||||
FetchChannels::ResponseMsg(action_sender, Some(cancel_receiver)),
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
// Step 13
|
||||
Ok(ev)
|
||||
}
|
||||
|
@ -614,8 +621,11 @@ impl EventSourceTimeoutCallback {
|
|||
// Step 5.3
|
||||
if !event_source.last_event_id.borrow().is_empty() {
|
||||
//TODO(eijebong): Change this once typed header support custom values
|
||||
request.headers.insert(HeaderName::from_static("last-event-id"),
|
||||
HeaderValue::from_str(&String::from(event_source.last_event_id.borrow().clone())).unwrap());
|
||||
request.headers.insert(
|
||||
HeaderName::from_static("last-event-id"),
|
||||
HeaderValue::from_str(&String::from(event_source.last_event_id.borrow().clone()))
|
||||
.unwrap(),
|
||||
);
|
||||
}
|
||||
// Step 5.4
|
||||
global
|
||||
|
@ -623,6 +633,7 @@ impl EventSourceTimeoutCallback {
|
|||
.send(CoreResourceMsg::Fetch(
|
||||
request,
|
||||
FetchChannels::ResponseMsg(self.action_sender, None),
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -302,7 +302,8 @@ impl EventListeners {
|
|||
} else {
|
||||
None
|
||||
}
|
||||
}).collect()
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn has_listeners(&self) -> bool {
|
||||
|
|
|
@ -465,7 +465,8 @@ impl FileReader {
|
|||
task_source,
|
||||
canceller,
|
||||
)
|
||||
}).expect("Thread spawning failed");
|
||||
})
|
||||
.expect("Thread spawning failed");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -100,7 +100,8 @@ impl FileReaderSyncMethods for FileReaderSync {
|
|||
cx,
|
||||
CreateWith::Slice(&blob_contents),
|
||||
array_buffer.handle_mut()
|
||||
).is_ok()
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
|
||||
Ok(NonNull::new_unchecked(array_buffer.get()))
|
||||
|
|
|
@ -135,7 +135,8 @@ impl FormDataMethods for FormData {
|
|||
FormDatumValue::File(ref b) => {
|
||||
FileOrUSVString::File(DomRoot::from_ref(&*b))
|
||||
},
|
||||
}).collect()
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -48,9 +48,9 @@ impl GainNode {
|
|||
node.node_id(),
|
||||
ParamType::Gain,
|
||||
AutomationRate::A_rate,
|
||||
*options.gain, // default value
|
||||
f32::MIN, // min value
|
||||
f32::MAX, // max value
|
||||
*options.gain, // default value
|
||||
f32::MIN, // min value
|
||||
f32::MAX, // max value
|
||||
);
|
||||
Ok(GainNode {
|
||||
node,
|
||||
|
|
|
@ -252,13 +252,18 @@ impl GlobalScope {
|
|||
}
|
||||
|
||||
pub fn add_uncaught_rejection(&self, rejection: HandleObject) {
|
||||
self.uncaught_rejections.borrow_mut().push(Heap::boxed(rejection.get()));
|
||||
self.uncaught_rejections
|
||||
.borrow_mut()
|
||||
.push(Heap::boxed(rejection.get()));
|
||||
}
|
||||
|
||||
pub fn remove_uncaught_rejection(&self, rejection: HandleObject) {
|
||||
let mut uncaught_rejections = self.uncaught_rejections.borrow_mut();
|
||||
|
||||
if let Some(index) = uncaught_rejections.iter().position(|promise| *promise == Heap::boxed(rejection.get())) {
|
||||
if let Some(index) = uncaught_rejections
|
||||
.iter()
|
||||
.position(|promise| *promise == Heap::boxed(rejection.get()))
|
||||
{
|
||||
uncaught_rejections.remove(index);
|
||||
}
|
||||
}
|
||||
|
@ -268,13 +273,18 @@ impl GlobalScope {
|
|||
}
|
||||
|
||||
pub fn add_consumed_rejection(&self, rejection: HandleObject) {
|
||||
self.consumed_rejections.borrow_mut().push(Heap::boxed(rejection.get()));
|
||||
self.consumed_rejections
|
||||
.borrow_mut()
|
||||
.push(Heap::boxed(rejection.get()));
|
||||
}
|
||||
|
||||
pub fn remove_consumed_rejection(&self, rejection: HandleObject) {
|
||||
let mut consumed_rejections = self.consumed_rejections.borrow_mut();
|
||||
|
||||
if let Some(index) = consumed_rejections.iter().position(|promise| *promise == Heap::boxed(rejection.get())) {
|
||||
if let Some(index) = consumed_rejections
|
||||
.iter()
|
||||
.position(|promise| *promise == Heap::boxed(rejection.get()))
|
||||
{
|
||||
consumed_rejections.remove(index);
|
||||
}
|
||||
}
|
||||
|
@ -639,11 +649,10 @@ impl GlobalScope {
|
|||
|
||||
/// Perform a microtask checkpoint.
|
||||
pub fn perform_a_microtask_checkpoint(&self) {
|
||||
self.microtask_queue
|
||||
.checkpoint(
|
||||
|_| Some(DomRoot::from_ref(self)),
|
||||
vec![DomRoot::from_ref(self)]
|
||||
);
|
||||
self.microtask_queue.checkpoint(
|
||||
|_| Some(DomRoot::from_ref(self)),
|
||||
vec![DomRoot::from_ref(self)],
|
||||
);
|
||||
}
|
||||
|
||||
/// Enqueue a microtask for subsequent execution.
|
||||
|
|
|
@ -87,14 +87,19 @@ impl HeadersMethods for Headers {
|
|||
}
|
||||
// Step 7
|
||||
let mut combined_value: Vec<u8> = vec![];
|
||||
if let Some(v) = self.header_list.borrow().get(HeaderName::from_str(&valid_name).unwrap()) {
|
||||
if let Some(v) = self
|
||||
.header_list
|
||||
.borrow()
|
||||
.get(HeaderName::from_str(&valid_name).unwrap())
|
||||
{
|
||||
combined_value = v.as_bytes().to_vec();
|
||||
combined_value.push(b',');
|
||||
}
|
||||
combined_value.extend(valid_value.iter().cloned());
|
||||
self.header_list
|
||||
.borrow_mut()
|
||||
.insert(HeaderName::from_str(&valid_name).unwrap(), HeaderValue::from_bytes(&combined_value).unwrap());
|
||||
self.header_list.borrow_mut().insert(
|
||||
HeaderName::from_str(&valid_name).unwrap(),
|
||||
HeaderValue::from_bytes(&combined_value).unwrap(),
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -129,9 +134,11 @@ impl HeadersMethods for Headers {
|
|||
fn Get(&self, name: ByteString) -> Fallible<Option<ByteString>> {
|
||||
// Step 1
|
||||
let valid_name = validate_name(name)?;
|
||||
Ok(self.header_list.borrow().get(HeaderName::from_str(&valid_name).unwrap()).map(|v| {
|
||||
ByteString::new(v.as_bytes().to_vec())
|
||||
}))
|
||||
Ok(self
|
||||
.header_list
|
||||
.borrow()
|
||||
.get(HeaderName::from_str(&valid_name).unwrap())
|
||||
.map(|v| ByteString::new(v.as_bytes().to_vec())))
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#dom-headers-has
|
||||
|
@ -169,9 +176,10 @@ impl HeadersMethods for Headers {
|
|||
}
|
||||
// Step 7
|
||||
// https://fetch.spec.whatwg.org/#concept-header-list-set
|
||||
self.header_list
|
||||
.borrow_mut()
|
||||
.insert(HeaderName::from_str(&valid_name).unwrap(), HeaderValue::from_bytes(&valid_value).unwrap());
|
||||
self.header_list.borrow_mut().insert(
|
||||
HeaderName::from_str(&valid_name).unwrap(),
|
||||
HeaderValue::from_bytes(&valid_value).unwrap(),
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +193,7 @@ impl Headers {
|
|||
for (name, value) in h.header_list.borrow().iter() {
|
||||
self.Append(
|
||||
ByteString::new(Vec::from(name.as_str())),
|
||||
ByteString::new(Vec::from(value.to_str().unwrap().as_bytes()))
|
||||
ByteString::new(Vec::from(value.to_str().unwrap().as_bytes())),
|
||||
)?;
|
||||
}
|
||||
Ok(())
|
||||
|
@ -251,7 +259,10 @@ impl Headers {
|
|||
|
||||
// https://fetch.spec.whatwg.org/#concept-header-extract-mime-type
|
||||
pub fn extract_mime_type(&self) -> Vec<u8> {
|
||||
self.header_list.borrow().get(header::CONTENT_TYPE).map_or(vec![], |v| v.as_bytes().to_owned())
|
||||
self.header_list
|
||||
.borrow()
|
||||
.get(header::CONTENT_TYPE)
|
||||
.map_or(vec![], |v| v.as_bytes().to_owned())
|
||||
}
|
||||
|
||||
pub fn sort_header_list(&self) -> Vec<(String, String)> {
|
||||
|
@ -299,14 +310,12 @@ fn is_cors_safelisted_request_content_type(value: &[u8]) -> bool {
|
|||
let value_mime_result: Result<Mime, _> = value_string.parse();
|
||||
match value_mime_result {
|
||||
Err(_) => false,
|
||||
Ok(value_mime) => {
|
||||
match (value_mime.type_(), value_mime.subtype()) {
|
||||
(mime::APPLICATION, mime::WWW_FORM_URLENCODED) |
|
||||
(mime::MULTIPART, mime::FORM_DATA) |
|
||||
(mime::TEXT, mime::PLAIN) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
Ok(value_mime) => match (value_mime.type_(), value_mime.subtype()) {
|
||||
(mime::APPLICATION, mime::WWW_FORM_URLENCODED) |
|
||||
(mime::MULTIPART, mime::FORM_DATA) |
|
||||
(mime::TEXT, mime::PLAIN) => true,
|
||||
_ => false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ use std::cell::Cell;
|
|||
use std::default::Default;
|
||||
use style::element_state::ElementState;
|
||||
|
||||
#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq )]
|
||||
#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)]
|
||||
enum ButtonType {
|
||||
Submit,
|
||||
Reset,
|
||||
|
|
|
@ -302,7 +302,7 @@ impl HTMLCanvasElement {
|
|||
// TODO: add a method in WebGL2RenderingContext to get the pixels.
|
||||
return None;
|
||||
},
|
||||
None => vec![0; size.height as usize * size.width as usize * 4]
|
||||
None => vec![0; size.height as usize * size.width as usize * 4],
|
||||
};
|
||||
|
||||
Some((data, size))
|
||||
|
|
|
@ -672,7 +672,8 @@ impl HTMLElement {
|
|||
.filter_map(|attr| {
|
||||
let raw_name = attr.local_name();
|
||||
to_camel_case(&raw_name)
|
||||
}).collect()
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-lfe-labels
|
||||
|
@ -684,16 +685,17 @@ impl HTMLElement {
|
|||
|
||||
// Traverse ancestors for implicitly associated <label> elements
|
||||
// https://html.spec.whatwg.org/multipage/#the-label-element:attr-label-for-4
|
||||
let ancestors = self.upcast::<Node>()
|
||||
.ancestors()
|
||||
.filter_map(DomRoot::downcast::<HTMLElement>)
|
||||
// If we reach a labelable element, we have a guarantee no ancestors above it
|
||||
// will be a label for this HTMLElement
|
||||
.take_while(|elem| !elem.is_labelable_element())
|
||||
.filter_map(DomRoot::downcast::<HTMLLabelElement>)
|
||||
.filter(|elem| !elem.upcast::<Element>().has_attribute(&local_name!("for")))
|
||||
.filter(|elem| elem.first_labelable_descendant().r() == Some(self))
|
||||
.map(DomRoot::upcast::<Node>);
|
||||
let ancestors = self
|
||||
.upcast::<Node>()
|
||||
.ancestors()
|
||||
.filter_map(DomRoot::downcast::<HTMLElement>)
|
||||
// If we reach a labelable element, we have a guarantee no ancestors above it
|
||||
// will be a label for this HTMLElement
|
||||
.take_while(|elem| !elem.is_labelable_element())
|
||||
.filter_map(DomRoot::downcast::<HTMLLabelElement>)
|
||||
.filter(|elem| !elem.upcast::<Element>().has_attribute(&local_name!("for")))
|
||||
.filter(|elem| elem.first_labelable_descendant().r() == Some(self))
|
||||
.map(DomRoot::upcast::<Node>);
|
||||
|
||||
let id = element.Id();
|
||||
let id = match &id as &str {
|
||||
|
|
|
@ -382,15 +382,25 @@ impl HTMLFormElement {
|
|||
// https://html.spec.whatwg.org/multipage/#submit-dialog
|
||||
},
|
||||
// https://html.spec.whatwg.org/multipage/#submit-mutate-action
|
||||
("http", FormMethod::FormGet) | ("https", FormMethod::FormGet) | ("data", FormMethod::FormGet) => {
|
||||
load_data.headers.typed_insert(ContentType::from(mime::APPLICATION_WWW_FORM_URLENCODED));
|
||||
("http", FormMethod::FormGet) |
|
||||
("https", FormMethod::FormGet) |
|
||||
("data", FormMethod::FormGet) => {
|
||||
load_data
|
||||
.headers
|
||||
.typed_insert(ContentType::from(mime::APPLICATION_WWW_FORM_URLENCODED));
|
||||
self.mutate_action_url(&mut form_data, load_data, encoding, &target_window);
|
||||
},
|
||||
// https://html.spec.whatwg.org/multipage/#submit-body
|
||||
("http", FormMethod::FormPost) | ("https", FormMethod::FormPost) => {
|
||||
load_data.method = Method::POST;
|
||||
self.submit_entity_body(&mut form_data, load_data, enctype, encoding, &target_window);
|
||||
}
|
||||
self.submit_entity_body(
|
||||
&mut form_data,
|
||||
load_data,
|
||||
enctype,
|
||||
encoding,
|
||||
&target_window,
|
||||
);
|
||||
},
|
||||
// https://html.spec.whatwg.org/multipage/#submit-get-action
|
||||
("file", _) |
|
||||
("about", _) |
|
||||
|
@ -445,7 +455,9 @@ impl HTMLFormElement {
|
|||
let bytes = match enctype {
|
||||
FormEncType::UrlEncoded => {
|
||||
let charset = encoding.name();
|
||||
load_data.headers.typed_insert(ContentType::from(mime::APPLICATION_WWW_FORM_URLENCODED));
|
||||
load_data
|
||||
.headers
|
||||
.typed_insert(ContentType::from(mime::APPLICATION_WWW_FORM_URLENCODED));
|
||||
|
||||
self.set_encoding_override(load_data.url.as_mut_url().query_pairs_mut())
|
||||
.clear()
|
||||
|
@ -458,12 +470,16 @@ impl HTMLFormElement {
|
|||
load_data.url.query().unwrap_or("").to_string().into_bytes()
|
||||
},
|
||||
FormEncType::FormDataEncoded => {
|
||||
let mime: Mime = format!("multipart/form-data; boundary={}", boundary).parse().unwrap();
|
||||
let mime: Mime = format!("multipart/form-data; boundary={}", boundary)
|
||||
.parse()
|
||||
.unwrap();
|
||||
load_data.headers.typed_insert(ContentType::from(mime));
|
||||
encode_multipart_form_data(form_data, boundary, encoding)
|
||||
},
|
||||
FormEncType::TextPlainEncoded => {
|
||||
load_data.headers.typed_insert(ContentType::from(mime::TEXT_PLAIN));
|
||||
load_data
|
||||
.headers
|
||||
.typed_insert(ContentType::from(mime::TEXT_PLAIN));
|
||||
self.encode_plaintext(form_data).into_bytes()
|
||||
},
|
||||
};
|
||||
|
@ -555,7 +571,8 @@ impl HTMLFormElement {
|
|||
} else {
|
||||
None
|
||||
}
|
||||
}).collect::<Vec<FormSubmittableElement>>();
|
||||
})
|
||||
.collect::<Vec<FormSubmittableElement>>();
|
||||
// Step 4
|
||||
if invalid_controls.is_empty() {
|
||||
return Ok(());
|
||||
|
@ -571,7 +588,8 @@ impl HTMLFormElement {
|
|||
return Some(field);
|
||||
}
|
||||
None
|
||||
}).collect::<Vec<FormSubmittableElement>>();
|
||||
})
|
||||
.collect::<Vec<FormSubmittableElement>>();
|
||||
// Step 7
|
||||
Err(unhandled_invalid_controls)
|
||||
}
|
||||
|
@ -1239,17 +1257,30 @@ pub fn encode_multipart_form_data(
|
|||
},
|
||||
FormDatumValue::File(ref f) => {
|
||||
let extra = if charset.to_lowercase() == "utf-8" {
|
||||
format!("filename=\"{}\"", String::from_utf8(f.name().as_bytes().into()).unwrap())
|
||||
format!(
|
||||
"filename=\"{}\"",
|
||||
String::from_utf8(f.name().as_bytes().into()).unwrap()
|
||||
)
|
||||
} else {
|
||||
format!("filename*=\"{}\"''{}", charset, http_percent_encode(f.name().as_bytes()))
|
||||
format!(
|
||||
"filename*=\"{}\"''{}",
|
||||
charset,
|
||||
http_percent_encode(f.name().as_bytes())
|
||||
)
|
||||
};
|
||||
|
||||
let content_disposition = format!("form-data; name=\"{}\"; {}", entry.name, extra);
|
||||
// https://tools.ietf.org/html/rfc7578#section-4.4
|
||||
let content_type: Mime = f.upcast::<Blob>().Type().parse().unwrap_or(mime::TEXT_PLAIN);
|
||||
let mut type_bytes = format!("Content-Disposition: {}\r\ncontent-type: {}\r\n\r\n",
|
||||
content_disposition,
|
||||
content_type).into_bytes();
|
||||
let content_type: Mime = f
|
||||
.upcast::<Blob>()
|
||||
.Type()
|
||||
.parse()
|
||||
.unwrap_or(mime::TEXT_PLAIN);
|
||||
let mut type_bytes = format!(
|
||||
"Content-Disposition: {}\r\ncontent-type: {}\r\n\r\n",
|
||||
content_disposition, content_type
|
||||
)
|
||||
.into_bytes();
|
||||
result.append(&mut type_bytes);
|
||||
|
||||
let mut bytes = f.upcast::<Blob>().get_bytes().unwrap_or(vec![]);
|
||||
|
|
|
@ -97,7 +97,8 @@ impl HTMLIFrameElement {
|
|||
} else {
|
||||
document_from_node(self).base_url().join(&url).ok()
|
||||
}
|
||||
}).unwrap_or_else(|| ServoUrl::parse("about:blank").unwrap())
|
||||
})
|
||||
.unwrap_or_else(|| ServoUrl::parse("about:blank").unwrap())
|
||||
}
|
||||
|
||||
pub fn navigate_or_reload_child_browsing_context(
|
||||
|
|
|
@ -566,12 +566,11 @@ impl HTMLImageElement {
|
|||
// TODO Handle unsupported mime type
|
||||
let mime = x.value().parse::<Mime>();
|
||||
match mime {
|
||||
Ok(m) =>
|
||||
match m.type_() {
|
||||
mime::IMAGE => (),
|
||||
_ => continue
|
||||
},
|
||||
_ => continue
|
||||
Ok(m) => match m.type_() {
|
||||
mime::IMAGE => (),
|
||||
_ => continue,
|
||||
},
|
||||
_ => continue,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1274,9 +1273,13 @@ impl HTMLImageElement {
|
|||
}
|
||||
|
||||
pub fn same_origin(&self, origin: &MutableOrigin) -> bool {
|
||||
self.current_request.borrow_mut().final_url.as_ref().map_or(false, |url| {
|
||||
url.scheme() == "data" || url.origin().same_origin(origin)
|
||||
})
|
||||
self.current_request
|
||||
.borrow_mut()
|
||||
.final_url
|
||||
.as_ref()
|
||||
.map_or(false, |url| {
|
||||
url.scheme() == "data" || url.origin().same_origin(origin)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1353,10 +1356,11 @@ impl LayoutHTMLImageElementHelpers for LayoutDom<HTMLImageElement> {
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn image_data(&self) -> (Option<Arc<Image>>, Option<ImageMetadata>) {
|
||||
let current_request = (*self.unsafe_get())
|
||||
.current_request
|
||||
.borrow_for_layout();
|
||||
(current_request.image.clone(), current_request.metadata.clone())
|
||||
let current_request = (*self.unsafe_get()).current_request.borrow_for_layout();
|
||||
(
|
||||
current_request.image.clone(),
|
||||
current_request.metadata.clone(),
|
||||
)
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
|
@ -1502,11 +1506,11 @@ impl HTMLImageElementMethods for HTMLImageElement {
|
|||
let elem = self.upcast::<Element>();
|
||||
let srcset_absent = !elem.has_attribute(&local_name!("srcset"));
|
||||
if !elem.has_attribute(&local_name!("src")) && srcset_absent {
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
let src = elem.get_string_attribute(&local_name!("src"));
|
||||
if srcset_absent && src.is_empty() {
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
let request = self.current_request.borrow();
|
||||
let request_state = request.state;
|
||||
|
@ -1582,8 +1586,10 @@ impl VirtualMethods for HTMLImageElement {
|
|||
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
||||
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
||||
match attr.local_name() {
|
||||
&local_name!("src") | &local_name!("srcset") |
|
||||
&local_name!("width") | &local_name!("crossorigin") |
|
||||
&local_name!("src") |
|
||||
&local_name!("srcset") |
|
||||
&local_name!("width") |
|
||||
&local_name!("crossorigin") |
|
||||
&local_name!("sizes") => self.update_the_image_data(),
|
||||
_ => {},
|
||||
}
|
||||
|
|
|
@ -944,8 +944,10 @@ impl HTMLInputElement {
|
|||
},
|
||||
|
||||
// Step 3.1: it's the "Checkbox" or "Radio Button" and whose checkedness is false.
|
||||
InputType::Radio | InputType::Checkbox => if !self.Checked() || name.is_empty() {
|
||||
return vec![];
|
||||
InputType::Radio | InputType::Checkbox => {
|
||||
if !self.Checked() || name.is_empty() {
|
||||
return vec![];
|
||||
}
|
||||
},
|
||||
|
||||
InputType::File => {
|
||||
|
@ -981,8 +983,10 @@ impl HTMLInputElement {
|
|||
InputType::Image => return vec![], // Unimplemented
|
||||
|
||||
// Step 3.1: it's not the "Image Button" and doesn't have a name attribute.
|
||||
_ => if name.is_empty() {
|
||||
return vec![];
|
||||
_ => {
|
||||
if name.is_empty() {
|
||||
return vec![];
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -1280,7 +1284,8 @@ impl VirtualMethods for HTMLInputElement {
|
|||
.map_or(DOMString::from(""), |a| {
|
||||
DOMString::from(a.summarize().value)
|
||||
}),
|
||||
).expect(
|
||||
)
|
||||
.expect(
|
||||
"Failed to set input value on type change to ValueMode::Value.",
|
||||
);
|
||||
self.value_dirty.set(false);
|
||||
|
|
|
@ -690,7 +690,10 @@ impl HTMLMediaElement {
|
|||
};
|
||||
let mut headers = HeaderMap::new();
|
||||
// FIXME(eijebong): Use typed headers once we have a constructor for the range header
|
||||
headers.insert(header::RANGE, HeaderValue::from_str(&format!("bytes={}-", offset.unwrap_or(0))).unwrap());
|
||||
headers.insert(
|
||||
header::RANGE,
|
||||
HeaderValue::from_str(&format!("bytes={}-", offset.unwrap_or(0))).unwrap(),
|
||||
);
|
||||
let request = RequestInit {
|
||||
url: self.resource_url.borrow().as_ref().unwrap().clone(),
|
||||
headers,
|
||||
|
@ -1139,7 +1142,8 @@ impl HTMLMediaElement {
|
|||
if self.is::<HTMLVideoElement>() {
|
||||
let video_elem = self.downcast::<HTMLVideoElement>().unwrap();
|
||||
if video_elem.get_video_width() != metadata.width ||
|
||||
video_elem.get_video_height() != metadata.height {
|
||||
video_elem.get_video_height() != metadata.height
|
||||
{
|
||||
video_elem.set_video_width(metadata.width);
|
||||
video_elem.set_video_height(metadata.height);
|
||||
let window = window_from_node(self);
|
||||
|
@ -1272,12 +1276,12 @@ impl HTMLMediaElementMethods for HTMLMediaElement {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-navigator-canplaytype
|
||||
fn CanPlayType(&self, type_: DOMString) -> CanPlayTypeResult {
|
||||
match type_.parse::<Mime>() {
|
||||
Ok(ref mime) if (mime.type_() == mime::APPLICATION && mime.subtype() == mime::OCTET_STREAM) => {
|
||||
CanPlayTypeResult::_empty
|
||||
},
|
||||
Err(_) => {
|
||||
Ok(ref mime)
|
||||
if (mime.type_() == mime::APPLICATION && mime.subtype() == mime::OCTET_STREAM) =>
|
||||
{
|
||||
CanPlayTypeResult::_empty
|
||||
},
|
||||
Err(_) => CanPlayTypeResult::_empty,
|
||||
_ => CanPlayTypeResult::Maybe,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -184,7 +184,8 @@ impl FetchResponseListener for ScriptContext {
|
|||
.and_then(|m| match m.status {
|
||||
Some((c, _)) => Some(c),
|
||||
_ => None,
|
||||
}).unwrap_or(0);
|
||||
})
|
||||
.unwrap_or(0);
|
||||
|
||||
self.status = match status_code {
|
||||
0 => Err(NetworkError::Internal(
|
||||
|
@ -437,20 +438,22 @@ impl HTMLScriptElement {
|
|||
};
|
||||
|
||||
// Preparation for step 23.
|
||||
let kind =
|
||||
if element.has_attribute(&local_name!("defer")) && was_parser_inserted && !r#async {
|
||||
// Step 23.a: classic, has src, has defer, was parser-inserted, is not async.
|
||||
ExternalScriptKind::Deferred
|
||||
} else if was_parser_inserted && !r#async {
|
||||
// Step 23.c: classic, has src, was parser-inserted, is not async.
|
||||
ExternalScriptKind::ParsingBlocking
|
||||
} else if !r#async && !self.non_blocking.get() {
|
||||
// Step 23.d: classic, has src, is not async, is not non-blocking.
|
||||
ExternalScriptKind::AsapInOrder
|
||||
} else {
|
||||
// Step 23.f: classic, has src.
|
||||
ExternalScriptKind::Asap
|
||||
};
|
||||
let kind = if element.has_attribute(&local_name!("defer")) &&
|
||||
was_parser_inserted &&
|
||||
!r#async
|
||||
{
|
||||
// Step 23.a: classic, has src, has defer, was parser-inserted, is not async.
|
||||
ExternalScriptKind::Deferred
|
||||
} else if was_parser_inserted && !r#async {
|
||||
// Step 23.c: classic, has src, was parser-inserted, is not async.
|
||||
ExternalScriptKind::ParsingBlocking
|
||||
} else if !r#async && !self.non_blocking.get() {
|
||||
// Step 23.d: classic, has src, is not async, is not non-blocking.
|
||||
ExternalScriptKind::AsapInOrder
|
||||
} else {
|
||||
// Step 23.f: classic, has src.
|
||||
ExternalScriptKind::Asap
|
||||
};
|
||||
|
||||
// Step 21.6.
|
||||
fetch_a_classic_script(
|
||||
|
|
|
@ -51,7 +51,9 @@ impl HTMLSourceElement {
|
|||
)
|
||||
}
|
||||
|
||||
fn iterate_next_html_image_element_siblings(next_siblings_iterator: impl Iterator<Item=Root<Dom<Node>>>) {
|
||||
fn iterate_next_html_image_element_siblings(
|
||||
next_siblings_iterator: impl Iterator<Item = Root<Dom<Node>>>,
|
||||
) {
|
||||
for next_sibling in next_siblings_iterator {
|
||||
if let Some(html_image_element_sibling) = next_sibling.downcast::<HTMLImageElement>() {
|
||||
html_image_element_sibling.update_the_image_data();
|
||||
|
@ -68,8 +70,10 @@ impl VirtualMethods for HTMLSourceElement {
|
|||
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
||||
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
||||
match attr.local_name() {
|
||||
&local_name!("srcset") | &local_name!("sizes") |
|
||||
&local_name!("media") | &local_name!("type") => {
|
||||
&local_name!("srcset") |
|
||||
&local_name!("sizes") |
|
||||
&local_name!("media") |
|
||||
&local_name!("type") => {
|
||||
let next_sibling_iterator = self.upcast::<Node>().following_siblings();
|
||||
HTMLSourceElement::iterate_next_html_image_element_siblings(next_sibling_iterator);
|
||||
},
|
||||
|
|
|
@ -139,7 +139,8 @@ impl HTMLTableElement {
|
|||
&local_name!("thead") => self.SetTHead(Some(§ion)),
|
||||
&local_name!("tfoot") => self.SetTFoot(Some(§ion)),
|
||||
_ => unreachable!("unexpected section type"),
|
||||
}.expect("unexpected section type");
|
||||
}
|
||||
.expect("unexpected section type");
|
||||
|
||||
section
|
||||
}
|
||||
|
@ -160,7 +161,8 @@ impl HTMLTableElement {
|
|||
.filter_map(|ref node| {
|
||||
node.downcast::<HTMLTableSectionElement>()
|
||||
.map(|_| Dom::from_ref(&**node))
|
||||
}).collect(),
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,11 +105,7 @@ impl HTMLTableRowElementMethods for HTMLTableRowElement {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-tr-deletecell
|
||||
fn DeleteCell(&self, index: i32) -> ErrorResult {
|
||||
let node = self.upcast::<Node>();
|
||||
node.delete_cell_or_row(
|
||||
index,
|
||||
|| self.Cells(),
|
||||
|n| n.is::<HTMLTableCellElement>(),
|
||||
)
|
||||
node.delete_cell_or_row(index, || self.Cells(), |n| n.is::<HTMLTableCellElement>())
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-tr-rowindex
|
||||
|
|
|
@ -384,7 +384,8 @@ impl<'a> Iterator for QuerySelectorIterator {
|
|||
}
|
||||
}
|
||||
None
|
||||
}).next()
|
||||
})
|
||||
.next()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1238,9 +1239,7 @@ impl LayoutNodeHelpers for LayoutDom<Node> {
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
fn image_data(&self) -> Option<(Option<StdArc<Image>>, Option<ImageMetadata>)> {
|
||||
unsafe {
|
||||
self.downcast::<HTMLImageElement>().map(|e| e.image_data())
|
||||
}
|
||||
unsafe { self.downcast::<HTMLImageElement>().map(|e| e.image_data()) }
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
|
@ -2837,10 +2836,12 @@ pub struct UnbindContext<'a> {
|
|||
|
||||
impl<'a> UnbindContext<'a> {
|
||||
/// Create a new `UnbindContext` value.
|
||||
fn new(parent: &'a Node,
|
||||
prev_sibling: Option<&'a Node>,
|
||||
next_sibling: Option<&'a Node>,
|
||||
cached_index: Option<u32>) -> Self {
|
||||
fn new(
|
||||
parent: &'a Node,
|
||||
prev_sibling: Option<&'a Node>,
|
||||
next_sibling: Option<&'a Node>,
|
||||
cached_index: Option<u32>,
|
||||
) -> Self {
|
||||
UnbindContext {
|
||||
index: Cell::new(cached_index),
|
||||
parent: parent,
|
||||
|
|
|
@ -85,7 +85,8 @@ impl PaintRenderingContext2D {
|
|||
) {
|
||||
let size = size * device_pixel_ratio;
|
||||
self.device_pixel_ratio.set(device_pixel_ratio);
|
||||
self.context.set_bitmap_dimensions(size.to_untyped().to_u32());
|
||||
self.context
|
||||
.set_bitmap_dimensions(size.to_untyped().to_u32());
|
||||
self.scale_by_device_pixel_ratio();
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,8 @@ impl PerformanceEntryList {
|
|||
name.as_ref().map_or(true, |name_| *e.name() == *name_) && entry_type
|
||||
.as_ref()
|
||||
.map_or(true, |type_| *e.entry_type() == *type_)
|
||||
}).map(|e| e.clone())
|
||||
})
|
||||
.map(|e| e.clone())
|
||||
.collect::<Vec<DomRoot<PerformanceEntry>>>();
|
||||
res.sort_by(|a, b| {
|
||||
a.start_time()
|
||||
|
@ -284,7 +285,8 @@ impl Performance {
|
|||
o.observer.callback(),
|
||||
o.observer.entries(),
|
||||
)
|
||||
}).collect();
|
||||
})
|
||||
.collect();
|
||||
|
||||
// Step 7.3.
|
||||
for o in observers.iter() {
|
||||
|
|
|
@ -36,7 +36,7 @@ impl PromiseRejectionEvent {
|
|||
PromiseRejectionEvent {
|
||||
event: Event::new_inherited(),
|
||||
promise,
|
||||
reason: Heap::default()
|
||||
reason: Heap::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,21 +47,17 @@ impl PromiseRejectionEvent {
|
|||
bubbles: EventBubbles,
|
||||
cancelable: EventCancelable,
|
||||
promise: Rc<Promise>,
|
||||
reason: HandleValue
|
||||
reason: HandleValue,
|
||||
) -> DomRoot<Self> {
|
||||
let ev = reflect_dom_object(
|
||||
Box::new(PromiseRejectionEvent::new_inherited(promise)),
|
||||
global,
|
||||
PromiseRejectionEventBinding::Wrap
|
||||
PromiseRejectionEventBinding::Wrap,
|
||||
);
|
||||
|
||||
{
|
||||
let event = ev.upcast::<Event>();
|
||||
event.init_event(
|
||||
type_,
|
||||
bool::from(bubbles),
|
||||
bool::from(cancelable)
|
||||
);
|
||||
event.init_event(type_, bool::from(bubbles), bool::from(cancelable));
|
||||
|
||||
ev.reason.set(reason.get());
|
||||
}
|
||||
|
@ -72,12 +68,12 @@ impl PromiseRejectionEvent {
|
|||
pub fn Constructor(
|
||||
global: &GlobalScope,
|
||||
type_: DOMString,
|
||||
init: RootedTraceableBox<PromiseRejectionEventBinding::PromiseRejectionEventInit>
|
||||
init: RootedTraceableBox<PromiseRejectionEventBinding::PromiseRejectionEventInit>,
|
||||
) -> Fallible<DomRoot<Self>> {
|
||||
let reason = init.reason.handle();
|
||||
let promise = match init.promise.as_ref() {
|
||||
Some(promise) => promise.clone(),
|
||||
None => Promise::new(global)
|
||||
None => Promise::new(global),
|
||||
};
|
||||
let bubbles = EventBubbles::from(init.parent.bubbles);
|
||||
let cancelable = EventCancelable::from(init.parent.cancelable);
|
||||
|
@ -88,7 +84,7 @@ impl PromiseRejectionEvent {
|
|||
bubbles,
|
||||
cancelable,
|
||||
promise,
|
||||
reason
|
||||
reason,
|
||||
);
|
||||
Ok(event)
|
||||
}
|
||||
|
|
|
@ -59,20 +59,28 @@ impl RadioNodeList {
|
|||
impl RadioNodeListMethods for RadioNodeList {
|
||||
// https://html.spec.whatwg.org/multipage/#dom-radionodelist-value
|
||||
fn Value(&self) -> DOMString {
|
||||
self.upcast::<NodeList>().as_simple_list().iter().filter_map(|node| {
|
||||
// Step 1
|
||||
node.downcast::<HTMLInputElement>().and_then(|input| {
|
||||
if input.input_type() == InputType::Radio && input.Checked() {
|
||||
// Step 3-4
|
||||
let value = input.Value();
|
||||
Some(if value.is_empty() { DOMString::from("on") } else { value })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
self.upcast::<NodeList>()
|
||||
.as_simple_list()
|
||||
.iter()
|
||||
.filter_map(|node| {
|
||||
// Step 1
|
||||
node.downcast::<HTMLInputElement>().and_then(|input| {
|
||||
if input.input_type() == InputType::Radio && input.Checked() {
|
||||
// Step 3-4
|
||||
let value = input.Value();
|
||||
Some(if value.is_empty() {
|
||||
DOMString::from("on")
|
||||
} else {
|
||||
value
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
})
|
||||
}).next()
|
||||
// Step 2
|
||||
.unwrap_or(DOMString::from(""))
|
||||
.next()
|
||||
// Step 2
|
||||
.unwrap_or(DOMString::from(""))
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-radionodelist-value
|
||||
|
|
|
@ -836,7 +836,8 @@ impl RangeMethods for Range {
|
|||
start_offset,
|
||||
start_node.len() - start_offset,
|
||||
DOMString::new(),
|
||||
).unwrap();
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
// Step 8.
|
||||
|
|
|
@ -285,7 +285,8 @@ impl Request {
|
|||
}
|
||||
// Step 25.2
|
||||
let method = match init_method.as_str() {
|
||||
Some(s) => normalize_method(s).map_err(|e| Error::Type(format!("Method is not valid: {:?}", e)))?,
|
||||
Some(s) => normalize_method(s)
|
||||
.map_err(|e| Error::Type(format!("Method is not valid: {:?}", e)))?,
|
||||
None => return Err(Error::Type("Method is not a valid UTF8".to_string())),
|
||||
};
|
||||
// Step 25.3
|
||||
|
@ -375,10 +376,16 @@ impl Request {
|
|||
let req = r.request.borrow();
|
||||
let req_method = &req.method;
|
||||
match *req_method {
|
||||
HttpMethod::GET => return Err(Error::Type(
|
||||
"Init's body is non-null, and request method is GET".to_string())),
|
||||
HttpMethod::HEAD => return Err(Error::Type(
|
||||
"Init's body is non-null, and request method is HEAD".to_string())),
|
||||
HttpMethod::GET => {
|
||||
return Err(Error::Type(
|
||||
"Init's body is non-null, and request method is GET".to_string(),
|
||||
))
|
||||
},
|
||||
HttpMethod::HEAD => {
|
||||
return Err(Error::Type(
|
||||
"Init's body is non-null, and request method is HEAD".to_string(),
|
||||
))
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
@ -500,9 +507,7 @@ fn is_forbidden_method(m: &ByteString) -> bool {
|
|||
|
||||
// https://fetch.spec.whatwg.org/#cors-safelisted-method
|
||||
fn is_cors_safelisted_method(m: &HttpMethod) -> bool {
|
||||
m == &HttpMethod::GET ||
|
||||
m == &HttpMethod::HEAD ||
|
||||
m == &HttpMethod::POST
|
||||
m == &HttpMethod::GET || m == &HttpMethod::HEAD || m == &HttpMethod::POST
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#include-credentials
|
||||
|
|
|
@ -257,7 +257,8 @@ impl Tokenizer {
|
|||
to_tokenizer_sender,
|
||||
html_tokenizer_receiver,
|
||||
);
|
||||
}).expect("HTML Parser thread spawning failed");
|
||||
})
|
||||
.expect("HTML Parser thread spawning failed");
|
||||
|
||||
tokenizer
|
||||
}
|
||||
|
@ -273,7 +274,8 @@ impl Tokenizer {
|
|||
self.html_tokenizer_sender
|
||||
.send(ToHtmlTokenizerMsg::Feed {
|
||||
input: send_tendrils,
|
||||
}).unwrap();
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
loop {
|
||||
match self
|
||||
|
@ -715,7 +717,8 @@ impl TreeSink for Sink {
|
|||
.map(|attr| Attribute {
|
||||
name: attr.name,
|
||||
value: String::from(attr.value),
|
||||
}).collect();
|
||||
})
|
||||
.collect();
|
||||
|
||||
self.send_op(ParseOperation::CreateElement {
|
||||
node: node.id,
|
||||
|
@ -835,7 +838,8 @@ impl TreeSink for Sink {
|
|||
.map(|attr| Attribute {
|
||||
name: attr.name,
|
||||
value: String::from(attr.value),
|
||||
}).collect();
|
||||
})
|
||||
.collect();
|
||||
self.send_op(ParseOperation::AddAttrsIfMissing {
|
||||
target: target.id,
|
||||
attrs,
|
||||
|
|
|
@ -127,7 +127,8 @@ fn start_element<S: Serializer>(node: &Element, serializer: &mut S) -> io::Resul
|
|||
let qname = QualName::new(None, attr.namespace().clone(), attr.local_name().clone());
|
||||
let value = attr.value().clone();
|
||||
(qname, value)
|
||||
}).collect::<Vec<_>>();
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let attr_refs = attrs.iter().map(|&(ref qname, ref value)| {
|
||||
let ar: AttrRef = (&qname, &**value);
|
||||
ar
|
||||
|
|
|
@ -722,8 +722,9 @@ impl FetchResponseListener for ParserContext {
|
|||
let doc_body = DomRoot::upcast::<Node>(doc.GetBody().unwrap());
|
||||
let img = HTMLImageElement::new(local_name!("img"), None, doc);
|
||||
img.SetSrc(DOMString::from(self.url.to_string()));
|
||||
doc_body.AppendChild(&DomRoot::upcast::<Node>(img)).expect("Appending failed");
|
||||
|
||||
doc_body
|
||||
.AppendChild(&DomRoot::upcast::<Node>(img))
|
||||
.expect("Appending failed");
|
||||
},
|
||||
Some(ref mime) if mime.type_() == mime::TEXT && mime.subtype() == mime::PLAIN => {
|
||||
// https://html.spec.whatwg.org/multipage/#read-text
|
||||
|
@ -750,17 +751,20 @@ impl FetchResponseListener for ParserContext {
|
|||
}
|
||||
},
|
||||
// Handle text/xml, application/xml
|
||||
Some(ref mime) if (mime.type_() == mime::TEXT && mime.subtype() == mime::XML) ||
|
||||
(mime.type_() == mime::APPLICATION && mime.subtype() == mime::XML) => {},
|
||||
Some(ref mime) if mime.type_() == mime::APPLICATION &&
|
||||
mime.subtype().as_str() == "xhtml" &&
|
||||
mime.suffix() == Some(mime::XML)
|
||||
=> {}, // Handle xhtml (application/xhtml+xml)
|
||||
Some(ref mime)
|
||||
if (mime.type_() == mime::TEXT && mime.subtype() == mime::XML) ||
|
||||
(mime.type_() == mime::APPLICATION && mime.subtype() == mime::XML) => {},
|
||||
Some(ref mime)
|
||||
if mime.type_() == mime::APPLICATION &&
|
||||
mime.subtype().as_str() == "xhtml" &&
|
||||
mime.suffix() == Some(mime::XML) => {}, // Handle xhtml (application/xhtml+xml)
|
||||
Some(ref mime) => {
|
||||
// Show warning page for unknown mime types.
|
||||
let page = format!("<html><body><p>Unknown content type ({}/{}).</p></body></html>",
|
||||
mime.type_().as_str(),
|
||||
mime.subtype().as_str());
|
||||
let page = format!(
|
||||
"<html><body><p>Unknown content type ({}/{}).</p></body></html>",
|
||||
mime.type_().as_str(),
|
||||
mime.subtype().as_str()
|
||||
);
|
||||
self.is_synthesized_document = true;
|
||||
parser.push_string_input_chunk(page);
|
||||
parser.parse_sync();
|
||||
|
|
|
@ -63,7 +63,8 @@ impl StorageMethods for Storage {
|
|||
sender,
|
||||
self.get_url(),
|
||||
self.storage_type,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
receiver.recv().unwrap() as u32
|
||||
}
|
||||
|
||||
|
@ -77,7 +78,8 @@ impl StorageMethods for Storage {
|
|||
self.get_url(),
|
||||
self.storage_type,
|
||||
index,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
receiver.recv().unwrap().map(DOMString::from)
|
||||
}
|
||||
|
||||
|
@ -138,7 +140,8 @@ impl StorageMethods for Storage {
|
|||
sender,
|
||||
self.get_url(),
|
||||
self.storage_type,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
if receiver.recv().unwrap() {
|
||||
self.broadcast_change_notification(None, None, None);
|
||||
}
|
||||
|
@ -153,7 +156,8 @@ impl StorageMethods for Storage {
|
|||
sender,
|
||||
self.get_url(),
|
||||
self.storage_type,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
receiver
|
||||
.recv()
|
||||
.unwrap()
|
||||
|
@ -224,6 +228,7 @@ impl Storage {
|
|||
event.upcast::<Event>().fire(global.upcast());
|
||||
}),
|
||||
global.upcast(),
|
||||
).unwrap();
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,11 +141,22 @@ impl StorageEventMethods for StorageEvent {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-storageevent-initstorageevent
|
||||
fn InitStorageEvent(&self, type_: DOMString, bubbles: bool, cancelable: bool, key:
|
||||
Option<DOMString>, oldValue: Option<DOMString>, newValue:
|
||||
Option<DOMString>, url: USVString, storageArea: Option<&Storage>)
|
||||
{
|
||||
self.event.init_event(Atom::from(type_), bool::from(bubbles), bool::from(cancelable));
|
||||
fn InitStorageEvent(
|
||||
&self,
|
||||
type_: DOMString,
|
||||
bubbles: bool,
|
||||
cancelable: bool,
|
||||
key: Option<DOMString>,
|
||||
oldValue: Option<DOMString>,
|
||||
newValue: Option<DOMString>,
|
||||
url: USVString,
|
||||
storageArea: Option<&Storage>,
|
||||
) {
|
||||
self.event.init_event(
|
||||
Atom::from(type_),
|
||||
bool::from(bubbles),
|
||||
bool::from(cancelable),
|
||||
);
|
||||
*self.key.borrow_mut() = key;
|
||||
*self.old_value.borrow_mut() = oldValue;
|
||||
*self.new_value.borrow_mut() = newValue;
|
||||
|
|
|
@ -63,9 +63,7 @@ pub struct TimeRangesContainer {
|
|||
|
||||
impl TimeRangesContainer {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
ranges: Vec::new(),
|
||||
}
|
||||
Self { ranges: Vec::new() }
|
||||
}
|
||||
|
||||
pub fn len(&self) -> u32 {
|
||||
|
@ -73,11 +71,17 @@ impl TimeRangesContainer {
|
|||
}
|
||||
|
||||
pub fn start(&self, index: u32) -> Result<f64, TimeRangesError> {
|
||||
self.ranges.get(index as usize).map(|r| r.start).ok_or(TimeRangesError::OutOfRange)
|
||||
self.ranges
|
||||
.get(index as usize)
|
||||
.map(|r| r.start)
|
||||
.ok_or(TimeRangesError::OutOfRange)
|
||||
}
|
||||
|
||||
pub fn end(&self, index: u32) -> Result<f64, TimeRangesError> {
|
||||
self.ranges.get(index as usize).map(|r| r.end).ok_or(TimeRangesError::OutOfRange)
|
||||
self.ranges
|
||||
.get(index as usize)
|
||||
.map(|r| r.end)
|
||||
.ok_or(TimeRangesError::OutOfRange)
|
||||
}
|
||||
|
||||
pub fn add(&mut self, start: f64, end: f64) -> Result<(), TimeRangesError> {
|
||||
|
@ -93,13 +97,16 @@ impl TimeRangesContainer {
|
|||
// in between two ranges.
|
||||
let mut idx = 0;
|
||||
while idx < self.ranges.len() {
|
||||
if new_range.is_overlapping(&self.ranges[idx]) || new_range.is_contiguous(&self.ranges[idx]) {
|
||||
if new_range.is_overlapping(&self.ranges[idx]) ||
|
||||
new_range.is_contiguous(&self.ranges[idx])
|
||||
{
|
||||
// The ranges are either overlapping or contiguous,
|
||||
// we need to merge the new range with the existing one.
|
||||
new_range.union(&self.ranges[idx]);
|
||||
self.ranges.remove(idx);
|
||||
} else if new_range.is_before(&self.ranges[idx]) &&
|
||||
(idx == 0 || self.ranges[idx - 1].is_before(&new_range)) {
|
||||
(idx == 0 || self.ranges[idx - 1].is_before(&new_range))
|
||||
{
|
||||
// We are exactly after the current previous range and before the current
|
||||
// range, while not overlapping with none of them.
|
||||
// Or we are simply at the beginning.
|
||||
|
@ -155,9 +162,7 @@ impl TimeRangesMethods for TimeRanges {
|
|||
.borrow()
|
||||
.start(index)
|
||||
.map(Finite::wrap)
|
||||
.map_err(|_| {
|
||||
Error::IndexSize
|
||||
})
|
||||
.map_err(|_| Error::IndexSize)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-timeranges-end
|
||||
|
@ -166,8 +171,6 @@ impl TimeRangesMethods for TimeRanges {
|
|||
.borrow()
|
||||
.end(index)
|
||||
.map(Finite::wrap)
|
||||
.map_err(|_| {
|
||||
Error::IndexSize
|
||||
})
|
||||
.map_err(|_| Error::IndexSize)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ impl URL {
|
|||
return Err(Error::Type(format!("could not parse base: {}", error)));
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
// Step 3.
|
||||
let parsed_url = match ServoUrl::parse_with_base(parsed_base.as_ref(), &url.0) {
|
||||
|
@ -121,7 +121,7 @@ impl URL {
|
|||
/*
|
||||
If the value provided for the url argument is not a Blob URL OR
|
||||
if the value provided for the url argument does not have an entry in the Blob URL Store,
|
||||
|
||||
|
||||
this method call does nothing. User agents may display a message on the error console.
|
||||
*/
|
||||
let origin = get_blob_origin(&global.get_url());
|
||||
|
|
|
@ -108,7 +108,8 @@ impl URLSearchParamsMethods for URLSearchParams {
|
|||
} else {
|
||||
None
|
||||
}
|
||||
}).collect()
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlsearchparams-has
|
||||
|
|
|
@ -213,7 +213,8 @@ impl VRDisplayMethods for VRDisplay {
|
|||
self.depth_near.get(),
|
||||
self.depth_far.get(),
|
||||
sender,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
return match receiver.recv().unwrap() {
|
||||
Ok(data) => {
|
||||
frameData.update(&data);
|
||||
|
@ -239,7 +240,8 @@ impl VRDisplayMethods for VRDisplay {
|
|||
self.global().pipeline_id(),
|
||||
self.DisplayId(),
|
||||
sender,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
if let Ok(data) = receiver.recv().unwrap() {
|
||||
// Some VRDisplay data might change after calling ResetPose()
|
||||
*self.display.borrow_mut() = data;
|
||||
|
@ -352,7 +354,8 @@ impl VRDisplayMethods for VRDisplay {
|
|||
self.global().pipeline_id(),
|
||||
self.display.borrow().display_id,
|
||||
sender,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
match receiver.recv().unwrap() {
|
||||
Ok(()) => {
|
||||
*self.layer.borrow_mut() = layer_bounds;
|
||||
|
@ -387,7 +390,8 @@ impl VRDisplayMethods for VRDisplay {
|
|||
self.global().pipeline_id(),
|
||||
self.display.borrow().display_id,
|
||||
Some(sender),
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
match receiver.recv().unwrap() {
|
||||
Ok(()) => {
|
||||
self.stop_present();
|
||||
|
@ -557,7 +561,8 @@ impl VRDisplay {
|
|||
task,
|
||||
Some(pipeline_id),
|
||||
TaskSourceName::DOMManipulation,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
|
||||
// Run Sync Poses in parallell on Render thread
|
||||
let msg = WebVRCommand::SyncPoses(display_id, near, far, sync_sender.clone());
|
||||
|
@ -573,7 +578,8 @@ impl VRDisplay {
|
|||
return;
|
||||
}
|
||||
}
|
||||
}).expect("Thread spawning failed");
|
||||
})
|
||||
.expect("Thread spawning failed");
|
||||
}
|
||||
|
||||
fn stop_present(&self) {
|
||||
|
@ -595,7 +601,8 @@ impl VRDisplay {
|
|||
self.global().pipeline_id(),
|
||||
self.display.borrow().display_id,
|
||||
None,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
self.stop_present();
|
||||
}
|
||||
|
||||
|
|
|
@ -27,9 +27,11 @@ impl EXTColorBufferHalfFloat {
|
|||
impl WebGLExtension for EXTColorBufferHalfFloat {
|
||||
type Extension = EXTColorBufferHalfFloat;
|
||||
fn new(ctx: &WebGLRenderingContext) -> DomRoot<EXTColorBufferHalfFloat> {
|
||||
reflect_dom_object(Box::new(EXTColorBufferHalfFloat::new_inherited()),
|
||||
&*ctx.global(),
|
||||
EXTColorBufferHalfFloatBinding::Wrap)
|
||||
reflect_dom_object(
|
||||
Box::new(EXTColorBufferHalfFloat::new_inherited()),
|
||||
&*ctx.global(),
|
||||
EXTColorBufferHalfFloatBinding::Wrap,
|
||||
)
|
||||
}
|
||||
|
||||
fn spec() -> WebGLExtensionSpec {
|
||||
|
@ -40,8 +42,7 @@ impl WebGLExtension for EXTColorBufferHalfFloat {
|
|||
OESTextureHalfFloat::is_supported(ext)
|
||||
}
|
||||
|
||||
fn enable(_ext: &WebGLExtensions) {
|
||||
}
|
||||
fn enable(_ext: &WebGLExtensions) {}
|
||||
|
||||
fn name() -> &'static str {
|
||||
"EXT_color_buffer_half_float"
|
||||
|
|
|
@ -27,9 +27,11 @@ impl WEBGLColorBufferFloat {
|
|||
impl WebGLExtension for WEBGLColorBufferFloat {
|
||||
type Extension = WEBGLColorBufferFloat;
|
||||
fn new(ctx: &WebGLRenderingContext) -> DomRoot<WEBGLColorBufferFloat> {
|
||||
reflect_dom_object(Box::new(WEBGLColorBufferFloat::new_inherited()),
|
||||
&*ctx.global(),
|
||||
WEBGLColorBufferFloatBinding::Wrap)
|
||||
reflect_dom_object(
|
||||
Box::new(WEBGLColorBufferFloat::new_inherited()),
|
||||
&*ctx.global(),
|
||||
WEBGLColorBufferFloatBinding::Wrap,
|
||||
)
|
||||
}
|
||||
|
||||
fn spec() -> WebGLExtensionSpec {
|
||||
|
@ -40,8 +42,7 @@ impl WebGLExtension for WEBGLColorBufferFloat {
|
|||
OESTextureFloat::is_supported(ext)
|
||||
}
|
||||
|
||||
fn enable(_ext: &WebGLExtensions) {
|
||||
}
|
||||
fn enable(_ext: &WebGLExtensions) {}
|
||||
|
||||
fn name() -> &'static str {
|
||||
"WEBGL_color_buffer_float"
|
||||
|
|
|
@ -183,7 +183,8 @@ impl WebGLExtensions {
|
|||
}
|
||||
}
|
||||
v.1.is_supported(&self)
|
||||
}).map(|ref v| v.1.name())
|
||||
})
|
||||
.map(|ref v| v.1.name())
|
||||
.collect()
|
||||
}
|
||||
|
||||
|
|
|
@ -122,9 +122,9 @@ impl WebGLRenderbuffer {
|
|||
// Validate the internal_format, and save it for completeness
|
||||
// validation.
|
||||
let actual_format = match internal_format {
|
||||
constants::RGBA4 |
|
||||
constants::DEPTH_COMPONENT16 |
|
||||
constants::STENCIL_INDEX8 => internal_format,
|
||||
constants::RGBA4 | constants::DEPTH_COMPONENT16 | constants::STENCIL_INDEX8 => {
|
||||
internal_format
|
||||
},
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#6.8
|
||||
constants::DEPTH_STENCIL => WebGL2RenderingContextConstants::DEPTH24_STENCIL8,
|
||||
constants::RGB5_A1 => {
|
||||
|
@ -134,7 +134,7 @@ impl WebGLRenderbuffer {
|
|||
} else {
|
||||
WebGL2RenderingContextConstants::RGBA8
|
||||
}
|
||||
}
|
||||
},
|
||||
constants::RGB565 => {
|
||||
// RGB565 is not supported on desktop GL.
|
||||
if is_gles() {
|
||||
|
@ -142,16 +142,26 @@ impl WebGLRenderbuffer {
|
|||
} else {
|
||||
WebGL2RenderingContextConstants::RGB8
|
||||
}
|
||||
}
|
||||
},
|
||||
EXTColorBufferHalfFloatConstants::RGBA16F_EXT |
|
||||
EXTColorBufferHalfFloatConstants::RGB16F_EXT => {
|
||||
if !self.upcast().context().extension_manager().is_half_float_buffer_renderable() {
|
||||
if !self
|
||||
.upcast()
|
||||
.context()
|
||||
.extension_manager()
|
||||
.is_half_float_buffer_renderable()
|
||||
{
|
||||
return Err(WebGLError::InvalidEnum);
|
||||
}
|
||||
internal_format
|
||||
},
|
||||
WEBGLColorBufferFloatConstants::RGBA32F_EXT => {
|
||||
if !self.upcast().context().extension_manager().is_float_buffer_renderable() {
|
||||
if !self
|
||||
.upcast()
|
||||
.context()
|
||||
.extension_manager()
|
||||
.is_float_buffer_renderable()
|
||||
{
|
||||
return Err(WebGLError::InvalidEnum);
|
||||
}
|
||||
internal_format
|
||||
|
|
|
@ -312,7 +312,9 @@ impl WebGLRenderingContext {
|
|||
|
||||
#[inline]
|
||||
pub fn send_command(&self, command: WebGLCommand) {
|
||||
self.webgl_sender.send(command, capture_webgl_backtrace(self)).unwrap();
|
||||
self.webgl_sender
|
||||
.send(command, capture_webgl_backtrace(self))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -570,7 +572,7 @@ impl WebGLRenderingContext {
|
|||
TexImageSource::HTMLVideoElement(_) => {
|
||||
// TODO: https://github.com/servo/servo/issues/6711
|
||||
return Ok(None);
|
||||
}
|
||||
},
|
||||
}))
|
||||
}
|
||||
|
||||
|
@ -1427,7 +1429,8 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
cx,
|
||||
CreateWith::Slice(&receiver.recv().unwrap()),
|
||||
rval.handle_mut(),
|
||||
).unwrap();
|
||||
)
|
||||
.unwrap();
|
||||
ObjectValue(rval.get())
|
||||
},
|
||||
Parameter::Int4(param) => {
|
||||
|
@ -1438,7 +1441,8 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
cx,
|
||||
CreateWith::Slice(&receiver.recv().unwrap()),
|
||||
rval.handle_mut(),
|
||||
).unwrap();
|
||||
)
|
||||
.unwrap();
|
||||
ObjectValue(rval.get())
|
||||
},
|
||||
Parameter::Float(param) => {
|
||||
|
@ -1454,7 +1458,8 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
cx,
|
||||
CreateWith::Slice(&receiver.recv().unwrap()),
|
||||
rval.handle_mut(),
|
||||
).unwrap();
|
||||
)
|
||||
.unwrap();
|
||||
ObjectValue(rval.get())
|
||||
},
|
||||
Parameter::Float4(param) => {
|
||||
|
@ -1465,7 +1470,8 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
cx,
|
||||
CreateWith::Slice(&receiver.recv().unwrap()),
|
||||
rval.handle_mut(),
|
||||
).unwrap();
|
||||
)
|
||||
.unwrap();
|
||||
ObjectValue(rval.get())
|
||||
},
|
||||
}
|
||||
|
@ -2895,7 +2901,9 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
}
|
||||
|
||||
let (sender, receiver) = ipc::bytes_channel().unwrap();
|
||||
self.send_command(WebGLCommand::ReadPixels(src_rect, format, pixel_type, sender));
|
||||
self.send_command(WebGLCommand::ReadPixels(
|
||||
src_rect, format, pixel_type, sender,
|
||||
));
|
||||
let src = receiver.recv().unwrap();
|
||||
|
||||
let src_row_len = src_rect.size.width as usize * bytes_per_pixel as usize;
|
||||
|
@ -3467,7 +3475,8 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
cx,
|
||||
CreateWith::Slice(&value),
|
||||
rval.handle_mut(),
|
||||
).unwrap();
|
||||
)
|
||||
.unwrap();
|
||||
ObjectValue(rval.get())
|
||||
}
|
||||
|
||||
|
@ -3627,7 +3636,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
handle_potential_webgl_error!(
|
||||
self,
|
||||
self.current_vao()
|
||||
.vertex_attrib_pointer(index, size, type_, normalized, stride, offset, )
|
||||
.vertex_attrib_pointer(index, size, type_, normalized, stride, offset)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -4063,7 +4072,11 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
return self.webgl_error(InvalidValue);
|
||||
}
|
||||
|
||||
let rb = handle_potential_webgl_error!(self, self.bound_renderbuffer.get().ok_or(InvalidOperation), return);
|
||||
let rb = handle_potential_webgl_error!(
|
||||
self,
|
||||
self.bound_renderbuffer.get().ok_or(InvalidOperation),
|
||||
return
|
||||
);
|
||||
handle_potential_webgl_error!(self, rb.storage(internal_format, width, height));
|
||||
if let Some(fb) = self.bound_framebuffer.get() {
|
||||
fb.invalidate_renderbuffer(&*rb);
|
||||
|
|
|
@ -429,7 +429,7 @@ impl WebSocketMethods for WebSocket {
|
|||
WebSocketRequestState::Connecting => {
|
||||
//Connection is not yet established
|
||||
/*By setting the state to closing, the open function
|
||||
will abort connecting the websocket*/
|
||||
will abort connecting the websocket*/
|
||||
self.ready_state.set(WebSocketRequestState::Closing);
|
||||
|
||||
let address = Trusted::new(self);
|
||||
|
@ -588,7 +588,8 @@ impl TaskOnce for MessageReceivedTask {
|
|||
cx,
|
||||
CreateWith::Slice(&data),
|
||||
array_buffer.handle_mut()
|
||||
).is_ok()
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
|
||||
(*array_buffer).to_jsval(cx, message.handle_mut());
|
||||
|
|
|
@ -1374,7 +1374,8 @@ impl Window {
|
|||
.send(Msg::UpdateScrollStateFromScript(ScrollState {
|
||||
scroll_id,
|
||||
scroll_offset: Vector2D::new(-x, -y),
|
||||
})).unwrap();
|
||||
}))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub fn update_viewport_for_scroll(&self, x: f32, y: f32) {
|
||||
|
@ -1852,7 +1853,8 @@ impl Window {
|
|||
pipeline_id,
|
||||
LoadData::new(url, Some(pipeline_id), referrer_policy, Some(doc.url())),
|
||||
replace,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -323,7 +323,11 @@ impl WorkletThreadPool {
|
|||
}
|
||||
|
||||
pub(crate) fn exit_worklet(&self, worklet_id: WorkletId) {
|
||||
for sender in &[&self.control_sender_0, &self.control_sender_1, &self.control_sender_2] {
|
||||
for sender in &[
|
||||
&self.control_sender_0,
|
||||
&self.control_sender_1,
|
||||
&self.control_sender_2,
|
||||
] {
|
||||
let _ = sender.send(WorkletControl::ExitWorklet(worklet_id));
|
||||
}
|
||||
self.wake_threads();
|
||||
|
|
|
@ -100,7 +100,8 @@ impl WorkletGlobalScope {
|
|||
name,
|
||||
properties,
|
||||
painter,
|
||||
}).expect("Worklet thread outlived script thread.");
|
||||
})
|
||||
.expect("Worklet thread outlived script thread.");
|
||||
}
|
||||
|
||||
/// The base URL of this global.
|
||||
|
|
|
@ -291,7 +291,8 @@ impl XMLHttpRequest {
|
|||
.send(Fetch(
|
||||
init,
|
||||
FetchChannels::ResponseMsg(action_sender, Some(cancellation_chan)),
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -461,7 +462,10 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
|||
None => value.into(),
|
||||
};
|
||||
|
||||
headers.insert(HeaderName::from_str(name_str).unwrap(), HeaderValue::from_bytes(&value).unwrap());
|
||||
headers.insert(
|
||||
HeaderName::from_str(name_str).unwrap(),
|
||||
HeaderValue::from_bytes(&value).unwrap(),
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -532,7 +536,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
|||
// Step 3
|
||||
let data = match *self.request_method.borrow() {
|
||||
Method::GET | Method::HEAD => None,
|
||||
_ => data
|
||||
_ => data,
|
||||
};
|
||||
// Step 4 (first half)
|
||||
let extracted_or_serialized = match data {
|
||||
|
@ -637,14 +641,18 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
|||
// XHR spec differs from http, and says UTF-8 should be in capitals,
|
||||
// instead of "utf-8", which is what Hyper defaults to. So not
|
||||
// using content types provided by Hyper.
|
||||
Some("UTF-8"),
|
||||
{
|
||||
Some("UTF-8")
|
||||
},
|
||||
_ => None,
|
||||
};
|
||||
|
||||
let mut content_type_set = false;
|
||||
if let Some(ref ct) = *content_type {
|
||||
if !request.headers.contains_key(header::CONTENT_TYPE) {
|
||||
request.headers.insert(header::CONTENT_TYPE, HeaderValue::from_str(ct).unwrap());
|
||||
request
|
||||
.headers
|
||||
.insert(header::CONTENT_TYPE, HeaderValue::from_str(ct).unwrap());
|
||||
content_type_set = true;
|
||||
}
|
||||
}
|
||||
|
@ -657,24 +665,26 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
|||
for param in mime.params() {
|
||||
if param.0 == mime::CHARSET {
|
||||
if !param.1.as_ref().eq_ignore_ascii_case(encoding) {
|
||||
let new_params: Vec<(Name, Name)> =
|
||||
mime.params()
|
||||
.filter(|p| p.0 != mime::CHARSET)
|
||||
.map(|p| (p.0, p.1))
|
||||
.collect();
|
||||
let new_params: Vec<
|
||||
(Name, Name),
|
||||
> = mime
|
||||
.params()
|
||||
.filter(|p| p.0 != mime::CHARSET)
|
||||
.map(|p| (p.0, p.1))
|
||||
.collect();
|
||||
|
||||
let new_mime =
|
||||
format!("{}/{}; charset={}{}{}",
|
||||
mime.type_().as_ref(),
|
||||
mime.subtype().as_ref(),
|
||||
encoding,
|
||||
if new_params.is_empty() { "" } else { "; " },
|
||||
new_params
|
||||
.iter()
|
||||
.map(|p| format!("{}={}", p.0, p.1))
|
||||
.collect::<Vec<String>>()
|
||||
.join("; ")
|
||||
);
|
||||
let new_mime = format!(
|
||||
"{}/{}; charset={}{}{}",
|
||||
mime.type_().as_ref(),
|
||||
mime.subtype().as_ref(),
|
||||
encoding,
|
||||
if new_params.is_empty() { "" } else { "; " },
|
||||
new_params
|
||||
.iter()
|
||||
.map(|p| format!("{}={}", p.0, p.1))
|
||||
.collect::<Vec<String>>()
|
||||
.join("; ")
|
||||
);
|
||||
let new_mime: Mime = new_mime.parse().unwrap();
|
||||
request.headers.typed_insert(ContentType::from(new_mime))
|
||||
}
|
||||
|
@ -744,15 +754,14 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
|||
let headers = self.filter_response_headers();
|
||||
let headers = headers.get_all(HeaderName::from_str(&name.as_str()?.to_lowercase()).ok()?);
|
||||
let mut first = true;
|
||||
let s = headers.iter()
|
||||
.fold(Vec::new(), |mut vec, value| {
|
||||
if !first {
|
||||
vec.extend(", ".as_bytes());
|
||||
}
|
||||
first = false;
|
||||
vec.extend(value.as_bytes());
|
||||
vec
|
||||
});
|
||||
let s = headers.iter().fold(Vec::new(), |mut vec, value| {
|
||||
if !first {
|
||||
vec.extend(", ".as_bytes());
|
||||
}
|
||||
first = false;
|
||||
vec.extend(value.as_bytes());
|
||||
vec
|
||||
});
|
||||
|
||||
// There was no header with that name so we never got to change that value
|
||||
if first {
|
||||
|
@ -808,9 +817,8 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
|||
*self.override_mime_type.borrow_mut() = Some(mime_no_params);
|
||||
// Step 4
|
||||
let value = override_mime.get_param(mime::CHARSET);
|
||||
*self.override_charset.borrow_mut() = value.and_then(|value| {
|
||||
Encoding::for_label(value.as_ref().as_bytes())
|
||||
});
|
||||
*self.override_charset.borrow_mut() =
|
||||
value.and_then(|value| Encoding::for_label(value.as_ref().as_bytes()));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -1130,18 +1138,24 @@ impl XMLHttpRequest {
|
|||
}
|
||||
|
||||
fn dispatch_progress_event(&self, upload: bool, type_: Atom, loaded: u64, total: Option<u64>) {
|
||||
let (total_length, length_computable) =
|
||||
if self.response_headers.borrow().contains_key(header::CONTENT_ENCODING) {
|
||||
(0, false)
|
||||
} else {
|
||||
(total.unwrap_or(0), total.is_some())
|
||||
};
|
||||
let progressevent = ProgressEvent::new(&self.global(),
|
||||
type_,
|
||||
EventBubbles::DoesNotBubble,
|
||||
EventCancelable::NotCancelable,
|
||||
length_computable, loaded,
|
||||
total_length);
|
||||
let (total_length, length_computable) = if self
|
||||
.response_headers
|
||||
.borrow()
|
||||
.contains_key(header::CONTENT_ENCODING)
|
||||
{
|
||||
(0, false)
|
||||
} else {
|
||||
(total.unwrap_or(0), total.is_some())
|
||||
};
|
||||
let progressevent = ProgressEvent::new(
|
||||
&self.global(),
|
||||
type_,
|
||||
EventBubbles::DoesNotBubble,
|
||||
EventCancelable::NotCancelable,
|
||||
length_computable,
|
||||
loaded,
|
||||
total_length,
|
||||
);
|
||||
let target = if upload {
|
||||
self.upload.upcast()
|
||||
} else {
|
||||
|
@ -1159,7 +1173,11 @@ impl XMLHttpRequest {
|
|||
|
||||
fn dispatch_response_progress_event(&self, type_: Atom) {
|
||||
let len = self.response.borrow().len() as u64;
|
||||
let total = self.response_headers.borrow().typed_get::<ContentLength>().map(|v| v.0);
|
||||
let total = self
|
||||
.response_headers
|
||||
.borrow()
|
||||
.typed_get::<ContentLength>()
|
||||
.map(|v| v.0);
|
||||
self.dispatch_progress_event(false, type_, len, total);
|
||||
}
|
||||
|
||||
|
@ -1202,7 +1220,11 @@ impl XMLHttpRequest {
|
|||
return response;
|
||||
}
|
||||
// Step 2
|
||||
let mime = self.final_mime_type().as_ref().map(|m| m.to_string()).unwrap_or("".to_owned());
|
||||
let mime = self
|
||||
.final_mime_type()
|
||||
.as_ref()
|
||||
.map(|m| m.to_string())
|
||||
.unwrap_or("".to_owned());
|
||||
|
||||
// Step 3, 4
|
||||
let bytes = self.response.borrow().to_vec();
|
||||
|
@ -1254,10 +1276,12 @@ impl XMLHttpRequest {
|
|||
}
|
||||
},
|
||||
// Step 7
|
||||
Some(ref mime) if (mime.type_() == mime::TEXT && mime.subtype() == mime::XML) ||
|
||||
(mime.type_() == mime::APPLICATION && mime.subtype() == mime::XML) => {
|
||||
Some(ref mime)
|
||||
if (mime.type_() == mime::TEXT && mime.subtype() == mime::XML) ||
|
||||
(mime.type_() == mime::APPLICATION && mime.subtype() == mime::XML) =>
|
||||
{
|
||||
temp_doc = self.handle_xml();
|
||||
},
|
||||
}
|
||||
None => {
|
||||
temp_doc = self.handle_xml();
|
||||
},
|
||||
|
@ -1441,11 +1465,9 @@ impl XMLHttpRequest {
|
|||
Some(ct) => {
|
||||
let mime: Mime = ct.into();
|
||||
let value = mime.get_param(mime::CHARSET);
|
||||
value.and_then(|value|{
|
||||
Encoding::for_label(value.as_ref().as_bytes())
|
||||
})
|
||||
}
|
||||
None => { None }
|
||||
value.and_then(|value| Encoding::for_label(value.as_ref().as_bytes()))
|
||||
},
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1455,8 +1477,8 @@ impl XMLHttpRequest {
|
|||
self.override_mime_type.borrow().clone()
|
||||
} else {
|
||||
match self.response_headers.borrow().typed_get::<ContentType>() {
|
||||
Some(ct) => { Some(ct.into()) },
|
||||
None => { None }
|
||||
Some(ct) => Some(ct.into()),
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -176,7 +176,8 @@ pub fn Fetch(
|
|||
.send(NetTraitsFetch(
|
||||
request_init,
|
||||
FetchChannels::ResponseMsg(action_sender, None),
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
|
||||
promise
|
||||
}
|
||||
|
|
|
@ -156,40 +156,51 @@ unsafe extern "C" fn promise_rejection_tracker(
|
|||
cx: *mut JSContext,
|
||||
promise: HandleObject,
|
||||
state: PromiseRejectionHandlingState,
|
||||
_data: *mut c_void
|
||||
_data: *mut c_void,
|
||||
) {
|
||||
// TODO: Step 2 - If script's muted errors is true, terminate these steps.
|
||||
|
||||
// Step 3.
|
||||
let global = GlobalScope::from_context(cx);
|
||||
|
||||
wrap_panic(AssertUnwindSafe(|| {
|
||||
match state {
|
||||
// Step 4.
|
||||
PromiseRejectionHandlingState::Unhandled => {
|
||||
global.add_uncaught_rejection(promise);
|
||||
},
|
||||
// Step 5.
|
||||
PromiseRejectionHandlingState::Handled => {
|
||||
// Step 5-1.
|
||||
if global.get_uncaught_rejections().borrow().contains(&Heap::boxed(promise.get())) {
|
||||
global.remove_uncaught_rejection(promise);
|
||||
return;
|
||||
}
|
||||
wrap_panic(
|
||||
AssertUnwindSafe(|| {
|
||||
match state {
|
||||
// Step 4.
|
||||
PromiseRejectionHandlingState::Unhandled => {
|
||||
global.add_uncaught_rejection(promise);
|
||||
},
|
||||
// Step 5.
|
||||
PromiseRejectionHandlingState::Handled => {
|
||||
// Step 5-1.
|
||||
if global
|
||||
.get_uncaught_rejections()
|
||||
.borrow()
|
||||
.contains(&Heap::boxed(promise.get()))
|
||||
{
|
||||
global.remove_uncaught_rejection(promise);
|
||||
return;
|
||||
}
|
||||
|
||||
// Step 5-2.
|
||||
if !global.get_consumed_rejections().borrow().contains(&Heap::boxed(promise.get())) {
|
||||
global.add_consumed_rejection(promise);
|
||||
return;
|
||||
}
|
||||
// Step 5-2.
|
||||
if !global
|
||||
.get_consumed_rejections()
|
||||
.borrow()
|
||||
.contains(&Heap::boxed(promise.get()))
|
||||
{
|
||||
global.add_consumed_rejection(promise);
|
||||
return;
|
||||
}
|
||||
|
||||
// Step 5-3.
|
||||
global.remove_consumed_rejection(promise);
|
||||
// Step 5-3.
|
||||
global.remove_consumed_rejection(promise);
|
||||
|
||||
// TODO: Step 5-4 - Queue a task to fire `rejectionhandled` event
|
||||
}
|
||||
};
|
||||
}), ());
|
||||
// TODO: Step 5-4 - Queue a task to fire `rejectionhandled` event
|
||||
},
|
||||
};
|
||||
}),
|
||||
(),
|
||||
);
|
||||
}
|
||||
|
||||
#[allow(unsafe_code, unrooted_must_root)]
|
||||
|
@ -201,11 +212,13 @@ pub fn notify_about_rejected_promises(global: &GlobalScope) {
|
|||
// Step 2.
|
||||
if global.get_uncaught_rejections().borrow().len() > 0 {
|
||||
// Step 1.
|
||||
let uncaught_rejections: Vec<TrustedPromise> = global.get_uncaught_rejections()
|
||||
let uncaught_rejections: Vec<TrustedPromise> = global
|
||||
.get_uncaught_rejections()
|
||||
.borrow()
|
||||
.iter()
|
||||
.map(|promise| {
|
||||
let promise = Promise::new_with_js_promise(Handle::from_raw(promise.handle()), cx);
|
||||
let promise =
|
||||
Promise::new_with_js_promise(Handle::from_raw(promise.handle()), cx);
|
||||
|
||||
TrustedPromise::new(promise)
|
||||
})
|
||||
|
|
|
@ -691,7 +691,8 @@ impl ScriptThreadFactory for ScriptThread {
|
|||
|
||||
// This must always be the very last operation performed before the thread completes
|
||||
failsafe.neuter();
|
||||
}).expect("Thread spawning failed");
|
||||
})
|
||||
.expect("Thread spawning failed");
|
||||
|
||||
(sender, receiver)
|
||||
}
|
||||
|
@ -890,7 +891,8 @@ impl ScriptThread {
|
|||
image_cache: script_thread.image_cache.clone(),
|
||||
};
|
||||
Rc::new(WorkletThreadPool::spawn(init))
|
||||
}).clone()
|
||||
})
|
||||
.clone()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -2539,7 +2541,8 @@ impl ScriptThread {
|
|||
.send((
|
||||
incomplete.pipeline_id,
|
||||
ScriptMsg::SetFinalUrl(final_url.clone()),
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
debug!(
|
||||
"ScriptThread: loading {} on pipeline {:?}",
|
||||
|
@ -2613,7 +2616,8 @@ impl ScriptThread {
|
|||
window.init_window_proxy(&window_proxy);
|
||||
|
||||
let last_modified = metadata.headers.as_ref().and_then(|headers| {
|
||||
headers.typed_get::<LastModified>()
|
||||
headers
|
||||
.typed_get::<LastModified>()
|
||||
.map(|tm| dom_last_modified(&tm.into()))
|
||||
});
|
||||
|
||||
|
@ -2622,18 +2626,22 @@ impl ScriptThread {
|
|||
Some(final_url.clone()),
|
||||
);
|
||||
|
||||
let content_type: Option<Mime> = metadata.content_type
|
||||
.map(Serde::into_inner)
|
||||
.map(Into::into);
|
||||
let content_type: Option<Mime> =
|
||||
metadata.content_type.map(Serde::into_inner).map(Into::into);
|
||||
|
||||
let is_html_document = match content_type {
|
||||
Some(ref mime) if mime.type_() == mime::APPLICATION &&
|
||||
mime.suffix() == Some(mime::XML) => IsHTMLDocument::NonHTMLDocument,
|
||||
Some(ref mime)
|
||||
if mime.type_() == mime::APPLICATION && mime.suffix() == Some(mime::XML) =>
|
||||
{
|
||||
IsHTMLDocument::NonHTMLDocument
|
||||
},
|
||||
|
||||
Some(ref mime) if
|
||||
(mime.type_() == mime::TEXT && mime.subtype() == mime::XML) ||
|
||||
(mime.type_() == mime::APPLICATION && mime.subtype() == mime::XML)
|
||||
=> IsHTMLDocument::NonHTMLDocument,
|
||||
Some(ref mime)
|
||||
if (mime.type_() == mime::TEXT && mime.subtype() == mime::XML) ||
|
||||
(mime.type_() == mime::APPLICATION && mime.subtype() == mime::XML) =>
|
||||
{
|
||||
IsHTMLDocument::NonHTMLDocument
|
||||
},
|
||||
_ => IsHTMLDocument::HTMLDocument,
|
||||
};
|
||||
|
||||
|
@ -2642,25 +2650,28 @@ impl ScriptThread {
|
|||
None => None,
|
||||
};
|
||||
|
||||
let referrer_policy = metadata.headers
|
||||
.as_ref()
|
||||
.map(Serde::deref)
|
||||
.and_then(|h| h.typed_get::<ReferrerPolicyHeader>())
|
||||
.map(ReferrerPolicy::from);
|
||||
let referrer_policy = metadata
|
||||
.headers
|
||||
.as_ref()
|
||||
.map(Serde::deref)
|
||||
.and_then(|h| h.typed_get::<ReferrerPolicyHeader>())
|
||||
.map(ReferrerPolicy::from);
|
||||
|
||||
let document = Document::new(&window,
|
||||
HasBrowsingContext::Yes,
|
||||
Some(final_url.clone()),
|
||||
incomplete.origin,
|
||||
is_html_document,
|
||||
content_type,
|
||||
last_modified,
|
||||
incomplete.activity,
|
||||
DocumentSource::FromParser,
|
||||
loader,
|
||||
referrer,
|
||||
referrer_policy,
|
||||
incomplete.canceller);
|
||||
let document = Document::new(
|
||||
&window,
|
||||
HasBrowsingContext::Yes,
|
||||
Some(final_url.clone()),
|
||||
incomplete.origin,
|
||||
is_html_document,
|
||||
content_type,
|
||||
last_modified,
|
||||
incomplete.activity,
|
||||
DocumentSource::FromParser,
|
||||
loader,
|
||||
referrer,
|
||||
referrer_policy,
|
||||
incomplete.canceller,
|
||||
);
|
||||
document.set_ready_state(DocumentReadyState::Loading);
|
||||
|
||||
self.documents
|
||||
|
@ -2719,7 +2730,8 @@ impl ScriptThread {
|
|||
ids,
|
||||
self.devtools_sender.clone(),
|
||||
page_info,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3042,7 +3054,8 @@ impl ScriptThread {
|
|||
.send((
|
||||
id,
|
||||
ScriptMsg::InitiateNavigateRequest(req_init, cancel_chan),
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
self.incomplete_loads.borrow_mut().push(incomplete);
|
||||
}
|
||||
|
||||
|
@ -3189,16 +3202,15 @@ impl ScriptThread {
|
|||
}
|
||||
|
||||
fn perform_a_microtask_checkpoint(&self) {
|
||||
let globals = self.documents.borrow()
|
||||
.iter()
|
||||
.map(|(_id, document)| document.global())
|
||||
.collect();
|
||||
let globals = self
|
||||
.documents
|
||||
.borrow()
|
||||
.iter()
|
||||
.map(|(_id, document)| document.global())
|
||||
.collect();
|
||||
|
||||
self.microtask_queue
|
||||
.checkpoint(
|
||||
|id| self.documents.borrow().find_global(id),
|
||||
globals
|
||||
)
|
||||
.checkpoint(|id| self.documents.borrow().find_global(id), globals)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,8 @@ impl ServiceWorkerManager {
|
|||
.spawn(move || {
|
||||
ServiceWorkerManager::new(own_sender, from_constellation, resource_port)
|
||||
.handle_message();
|
||||
}).expect("Thread spawning failed");
|
||||
})
|
||||
.expect("Thread spawning failed");
|
||||
}
|
||||
|
||||
pub fn get_matching_scope(&self, load_url: &ServoUrl) -> Option<ServoUrl> {
|
||||
|
|
|
@ -120,7 +120,11 @@ impl FetchResponseListener for StylesheetContext {
|
|||
mime.type_() == mime::TEXT && mime.subtype() == mime::CSS
|
||||
});
|
||||
|
||||
let data = if is_css { mem::replace(&mut self.data, vec![]) } else { vec![] };
|
||||
let data = if is_css {
|
||||
mem::replace(&mut self.data, vec![])
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
|
||||
// TODO: Get the actual value. http://dev.w3.org/csswg/css-syntax/#environment-encoding
|
||||
let environment_encoding = UTF_8;
|
||||
|
|
|
@ -84,7 +84,8 @@ impl<T: QueuedTaskConversion> TaskQueue<T> {
|
|||
return false;
|
||||
},
|
||||
}
|
||||
}).collect();
|
||||
})
|
||||
.collect();
|
||||
|
||||
for msg in incoming {
|
||||
// Immediately send non-throttled tasks for processing.
|
||||
|
|
|
@ -295,9 +295,7 @@ impl<T: ClipboardProvider> TextInput<T> {
|
|||
fn assert_ok_selection(&self) {
|
||||
debug!(
|
||||
"edit_point: {:?}, selection_origin: {:?}, direction: {:?}",
|
||||
self.edit_point,
|
||||
self.selection_origin,
|
||||
self.selection_direction
|
||||
self.edit_point, self.selection_origin, self.selection_direction
|
||||
);
|
||||
if let Some(begin) = self.selection_origin {
|
||||
debug_assert!(begin.line < self.lines.len());
|
||||
|
@ -532,8 +530,7 @@ impl<T: ClipboardProvider> TextInput<T> {
|
|||
fn update_selection_direction(&mut self) {
|
||||
debug!(
|
||||
"edit_point: {:?}, selection_origin: {:?}",
|
||||
self.edit_point,
|
||||
self.selection_origin
|
||||
self.edit_point, self.selection_origin
|
||||
);
|
||||
self.selection_direction = if Some(self.edit_point) < self.selection_origin {
|
||||
SelectionDirection::Backward
|
||||
|
|
|
@ -147,7 +147,8 @@ pub fn handle_get_browsing_context_id(
|
|||
.and_then(|node| {
|
||||
node.downcast::<HTMLIFrameElement>()
|
||||
.and_then(|elem| elem.browsing_context_id())
|
||||
}).ok_or(()),
|
||||
})
|
||||
.ok_or(()),
|
||||
WebDriverFrameId::Parent => documents
|
||||
.find_window(pipeline)
|
||||
.and_then(|window| {
|
||||
|
@ -155,7 +156,8 @@ pub fn handle_get_browsing_context_id(
|
|||
.window_proxy()
|
||||
.parent()
|
||||
.map(|parent| parent.browsing_context_id())
|
||||
}).ok_or(()),
|
||||
})
|
||||
.ok_or(()),
|
||||
};
|
||||
|
||||
reply.send(result).unwrap()
|
||||
|
@ -187,7 +189,8 @@ pub fn handle_find_elements_css(
|
|||
.and_then(|doc| {
|
||||
doc.QuerySelectorAll(DOMString::from(selector))
|
||||
.map_err(|_| ())
|
||||
}).map(|nodes| {
|
||||
})
|
||||
.map(|nodes| {
|
||||
nodes
|
||||
.iter()
|
||||
.map(|x| x.upcast::<Node>().unique_id())
|
||||
|
@ -217,7 +220,8 @@ pub fn handle_focus_element(
|
|||
},
|
||||
None => Err(()),
|
||||
},
|
||||
).unwrap();
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_get_active_element(
|
||||
|
@ -231,7 +235,8 @@ pub fn handle_get_active_element(
|
|||
.find_document(pipeline)
|
||||
.and_then(|doc| doc.GetActiveElement())
|
||||
.map(|elem| elem.upcast::<Node>().unique_id()),
|
||||
).unwrap();
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_get_cookies(
|
||||
|
@ -326,7 +331,8 @@ pub fn handle_add_cookie(
|
|||
Ok(())
|
||||
},
|
||||
(_, _) => Err(WebDriverCookieError::UnableToSetCookie),
|
||||
}).unwrap();
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_get_title(documents: &Documents, pipeline: PipelineId, reply: IpcSender<String>) {
|
||||
|
@ -382,7 +388,8 @@ pub fn handle_get_rect(
|
|||
},
|
||||
None => Err(()),
|
||||
},
|
||||
).unwrap();
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_get_text(
|
||||
|
@ -395,7 +402,8 @@ pub fn handle_get_text(
|
|||
.send(match find_node_by_unique_id(documents, pipeline, node_id) {
|
||||
Some(ref node) => Ok(node.GetTextContent().map_or("".to_owned(), String::from)),
|
||||
None => Err(()),
|
||||
}).unwrap();
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_get_name(
|
||||
|
@ -408,7 +416,8 @@ pub fn handle_get_name(
|
|||
.send(match find_node_by_unique_id(documents, pipeline, node_id) {
|
||||
Some(node) => Ok(String::from(node.downcast::<Element>().unwrap().TagName())),
|
||||
None => Err(()),
|
||||
}).unwrap();
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_get_attribute(
|
||||
|
@ -426,7 +435,8 @@ pub fn handle_get_attribute(
|
|||
.GetAttribute(DOMString::from(name))
|
||||
.map(String::from)),
|
||||
None => Err(()),
|
||||
}).unwrap();
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_get_css(
|
||||
|
@ -448,7 +458,8 @@ pub fn handle_get_css(
|
|||
))
|
||||
},
|
||||
None => Err(()),
|
||||
}).unwrap();
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_get_url(documents: &Documents, pipeline: PipelineId, reply: IpcSender<ServoUrl>) {
|
||||
|
@ -475,7 +486,8 @@ pub fn handle_is_enabled(
|
|||
},
|
||||
None => Err(()),
|
||||
},
|
||||
).unwrap();
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_is_selected(
|
||||
|
@ -500,5 +512,6 @@ pub fn handle_is_selected(
|
|||
},
|
||||
None => Err(()),
|
||||
},
|
||||
).unwrap();
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue