mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Fix a bunch of clippy lints
This commit is contained in:
parent
b1ca3d1cdf
commit
6b215f38ee
58 changed files with 281 additions and 356 deletions
|
@ -512,14 +512,12 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
|
|
||||||
(Msg::ScrollTimeout(timestamp), ShutdownState::NotShuttingDown) => {
|
(Msg::ScrollTimeout(timestamp), ShutdownState::NotShuttingDown) => {
|
||||||
debug!("scroll timeout, drawing unpainted content!");
|
debug!("scroll timeout, drawing unpainted content!");
|
||||||
match self.composition_request {
|
if let CompositionRequest::CompositeOnScrollTimeout(this_timestamp) =
|
||||||
CompositionRequest::CompositeOnScrollTimeout(this_timestamp) => {
|
self.composition_request {
|
||||||
if timestamp == this_timestamp {
|
if timestamp == this_timestamp {
|
||||||
self.composition_request = CompositionRequest::CompositeNow(
|
self.composition_request = CompositionRequest::CompositeNow(
|
||||||
CompositingReason::HitScrollTimeout)
|
CompositingReason::HitScrollTimeout)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -644,7 +642,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
if !self.pipeline_details.contains_key(&pipeline_id) {
|
if !self.pipeline_details.contains_key(&pipeline_id) {
|
||||||
self.pipeline_details.insert(pipeline_id, PipelineDetails::new());
|
self.pipeline_details.insert(pipeline_id, PipelineDetails::new());
|
||||||
}
|
}
|
||||||
return self.pipeline_details.get_mut(&pipeline_id).unwrap();
|
self.pipeline_details.get_mut(&pipeline_id).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pipeline(&self, pipeline_id: PipelineId) -> Option<&CompositionPipeline> {
|
pub fn pipeline(&self, pipeline_id: PipelineId) -> Option<&CompositionPipeline> {
|
||||||
|
@ -730,7 +728,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
root_layer.bounds.borrow_mut().size = Size2D::from_untyped(&frame_size);
|
root_layer.bounds.borrow_mut().size = Size2D::from_untyped(&frame_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return root_layer;
|
root_layer
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_pipeline_details_for_frame_tree(&mut self, frame_tree: &SendableFrameTree) {
|
fn create_pipeline_details_for_frame_tree(&mut self, frame_tree: &SendableFrameTree) {
|
||||||
|
@ -1223,11 +1221,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
result.layer.send_event(self, TouchEvent(TouchEventType::Up, identifier,
|
result.layer.send_event(self, TouchEvent(TouchEventType::Up, identifier,
|
||||||
result.point.to_untyped()));
|
result.point.to_untyped()));
|
||||||
}
|
}
|
||||||
match self.touch_handler.on_touch_up(identifier, point) {
|
if let TouchAction::Click = self.touch_handler.on_touch_up(identifier, point) {
|
||||||
TouchAction::Click => {
|
self.simulate_mouse_click(point);
|
||||||
self.simulate_mouse_click(point);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1882,7 +1877,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Some(HitTestResult { layer: layer, point: point_in_parent_layer });
|
Some(HitTestResult { layer: layer, point: point_in_parent_layer })
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_topmost_layer_at_point(&self,
|
fn find_topmost_layer_at_point(&self,
|
||||||
|
@ -2001,7 +1996,7 @@ fn find_layer_with_pipeline_and_layer_id_for_layer(layer: Rc<Layer<CompositorDat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return None;
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Window> CompositorEventListener for IOCompositor<Window> where Window: WindowMethods {
|
impl<Window> CompositorEventListener for IOCompositor<Window> where Window: WindowMethods {
|
||||||
|
|
|
@ -359,9 +359,9 @@ impl CompositorLayer for Layer<CompositorData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if result {
|
if result {
|
||||||
return ScrollEventResult::ScrollPositionChanged;
|
ScrollEventResult::ScrollPositionChanged
|
||||||
} else {
|
} else {
|
||||||
return ScrollEventResult::ScrollPositionUnchanged;
|
ScrollEventResult::ScrollPositionUnchanged
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,7 +414,7 @@ impl CompositorLayer for Layer<CompositorData> {
|
||||||
result |= child.scroll_layer_and_all_child_layers(offset_for_children);
|
result |= child.scroll_layer_and_all_child_layers(offset_for_children);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wants_scroll_events(&self) -> WantsScrollEventsFlag {
|
fn wants_scroll_events(&self) -> WantsScrollEventsFlag {
|
||||||
|
|
|
@ -155,14 +155,14 @@ impl TimerScheduler {
|
||||||
|
|
||||||
let ret = sel.wait();
|
let ret = sel.wait();
|
||||||
if ret == scheduler_handle.id() {
|
if ret == scheduler_handle.id() {
|
||||||
port.recv().ok().map(|req| Task::HandleRequest(req))
|
port.recv().ok().map(Task::HandleRequest)
|
||||||
} else if ret == timer_handle.id() {
|
} else if ret == timer_handle.id() {
|
||||||
timer_port.recv().ok().map(|_| Task::DispatchDueEvents)
|
timer_port.recv().ok().map(|_| Task::DispatchDueEvents)
|
||||||
} else {
|
} else {
|
||||||
panic!("unexpected select result!")
|
panic!("unexpected select result!")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
port.recv().ok().map(|req| Task::HandleRequest(req))
|
port.recv().ok().map(Task::HandleRequest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,8 +172,7 @@ impl TimerScheduler {
|
||||||
let schedule_for = precise_time_ns() + duration_ns;
|
let schedule_for = precise_time_ns() + duration_ns;
|
||||||
|
|
||||||
let previously_earliest = self.scheduled_events.borrow().peek()
|
let previously_earliest = self.scheduled_events.borrow().peek()
|
||||||
.map(|scheduled| scheduled.for_time)
|
.map_or(Length::new(u64::max_value()), |scheduled| scheduled.for_time);
|
||||||
.unwrap_or(Length::new(u64::max_value()));
|
|
||||||
|
|
||||||
self.scheduled_events.borrow_mut().push(ScheduledEvent {
|
self.scheduled_events.borrow_mut().push(ScheduledEvent {
|
||||||
request: request,
|
request: request,
|
||||||
|
|
|
@ -203,16 +203,15 @@ impl TouchHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_event_processed(&mut self, result: EventResult) {
|
pub fn on_event_processed(&mut self, result: EventResult) {
|
||||||
match self.state {
|
if let WaitingForScript = self.state {
|
||||||
WaitingForScript => self.state = match result {
|
self.state = match result {
|
||||||
EventResult::DefaultPrevented => DefaultPrevented,
|
EventResult::DefaultPrevented => DefaultPrevented,
|
||||||
EventResult::DefaultAllowed => match self.touch_count() {
|
EventResult::DefaultAllowed => match self.touch_count() {
|
||||||
1 => Touching,
|
1 => Touching,
|
||||||
2 => Pinching,
|
2 => Pinching,
|
||||||
_ => MultiTouch,
|
_ => MultiTouch,
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -340,9 +340,8 @@ impl NetworkEventActor {
|
||||||
// TODO: Send the correct values for all these fields.
|
// TODO: Send the correct values for all these fields.
|
||||||
let hSizeOption = self.response.headers.as_ref().map(|headers| headers.len() as u32);
|
let hSizeOption = self.response.headers.as_ref().map(|headers| headers.len() as u32);
|
||||||
let hSize = hSizeOption.unwrap_or(0);
|
let hSize = hSizeOption.unwrap_or(0);
|
||||||
let (status_code, status_message) =
|
let (status_code, status_message) = self.response.status.as_ref().
|
||||||
self.response.status.as_ref().map(|&RawStatus(ref code, ref text)| (*code, text.clone().into_owned())).
|
map_or((0, "".to_owned()), |&RawStatus(ref code, ref text)| (*code, text.clone().into_owned()));
|
||||||
unwrap_or((0, "".to_owned()));
|
|
||||||
// TODO: Send the correct values for remoteAddress and remotePort and http_version.
|
// TODO: Send the correct values for remoteAddress and remotePort and http_version.
|
||||||
ResponseStartMsg {
|
ResponseStartMsg {
|
||||||
httpVersion: "HTTP/1.1".to_owned(),
|
httpVersion: "HTTP/1.1".to_owned(),
|
||||||
|
|
|
@ -14,18 +14,18 @@ use std::io::{Read, Write};
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
|
|
||||||
pub trait JsonPacketStream {
|
pub trait JsonPacketStream {
|
||||||
fn write_json_packet<'a, T: Encodable>(&mut self, obj: &T);
|
fn write_json_packet<T: Encodable>(&mut self, obj: &T);
|
||||||
fn read_json_packet(&mut self) -> Result<Option<Json>, String>;
|
fn read_json_packet(&mut self) -> Result<Option<Json>, String>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl JsonPacketStream for TcpStream {
|
impl JsonPacketStream for TcpStream {
|
||||||
fn write_json_packet<'a, T: Encodable>(&mut self, obj: &T) {
|
fn write_json_packet<T: Encodable>(&mut self, obj: &T) {
|
||||||
let s = json::encode(obj).unwrap().replace("__type__", "type");
|
let s = json::encode(obj).unwrap().replace("__type__", "type");
|
||||||
println!("<- {}", s);
|
println!("<- {}", s);
|
||||||
write!(self, "{}:{}", s.len(), s).unwrap();
|
write!(self, "{}:{}", s.len(), s).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_json_packet<'a>(&mut self) -> Result<Option<Json>, String> {
|
fn read_json_packet(&mut self) -> Result<Option<Json>, String> {
|
||||||
// https://wiki.mozilla.org/Remote_Debugging_Protocol_Stream_Transport
|
// https://wiki.mozilla.org/Remote_Debugging_Protocol_Stream_Transport
|
||||||
// In short, each JSON packet is [ascii length]:[JSON data of given length]
|
// In short, each JSON packet is [ascii length]:[JSON data of given length]
|
||||||
let mut buffer = vec!();
|
let mut buffer = vec!();
|
||||||
|
|
|
@ -941,7 +941,7 @@ impl StackingContextLayerCreator {
|
||||||
return Some(LayerInfo::new(layer.id, ScrollPolicy::Scrollable, None));
|
return Some(LayerInfo::new(layer.id, ScrollPolicy::Scrollable, None));
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.last_child_layer_info;
|
self.last_child_layer_info
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -39,7 +39,7 @@ impl FontTemplates {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find a font in this family that matches a given descriptor.
|
/// Find a font in this family that matches a given descriptor.
|
||||||
fn find_font_for_style<'a>(&'a mut self, desc: &FontTemplateDescriptor, fctx: &FontContextHandle)
|
fn find_font_for_style(&mut self, desc: &FontTemplateDescriptor, fctx: &FontContextHandle)
|
||||||
-> Option<Arc<FontTemplateData>> {
|
-> Option<Arc<FontTemplateData>> {
|
||||||
// TODO(Issue #189): optimize lookup for
|
// TODO(Issue #189): optimize lookup for
|
||||||
// regular/bold/italic/bolditalic with fixed offsets and a
|
// regular/bold/italic/bolditalic with fixed offsets and a
|
||||||
|
@ -251,7 +251,7 @@ impl FontCache {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_font_in_local_family<'a>(&'a mut self, family_name: &LowercaseString, desc: &FontTemplateDescriptor)
|
fn find_font_in_local_family(&mut self, family_name: &LowercaseString, desc: &FontTemplateDescriptor)
|
||||||
-> Option<Arc<FontTemplateData>> {
|
-> Option<Arc<FontTemplateData>> {
|
||||||
// TODO(Issue #188): look up localized font family names if canonical name not found
|
// TODO(Issue #188): look up localized font family names if canonical name not found
|
||||||
// look up canonical name
|
// look up canonical name
|
||||||
|
@ -275,14 +275,13 @@ impl FontCache {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_font_in_web_family<'a>(&'a mut self, family: &FontFamily, desc: &FontTemplateDescriptor)
|
fn find_font_in_web_family(&mut self, family: &FontFamily, desc: &FontTemplateDescriptor)
|
||||||
-> Option<Arc<FontTemplateData>> {
|
-> Option<Arc<FontTemplateData>> {
|
||||||
let family_name = LowercaseString::new(family.name());
|
let family_name = LowercaseString::new(family.name());
|
||||||
|
|
||||||
if self.web_families.contains_key(&family_name) {
|
if self.web_families.contains_key(&family_name) {
|
||||||
let templates = self.web_families.get_mut(&family_name).unwrap();
|
let templates = self.web_families.get_mut(&family_name).unwrap();
|
||||||
let maybe_font = templates.find_font_for_style(desc, &self.font_context);
|
templates.find_font_for_style(desc, &self.font_context)
|
||||||
maybe_font
|
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,12 +166,12 @@ impl FontHandleMethods for FontHandle {
|
||||||
assert!(!self.face.is_null());
|
assert!(!self.face.is_null());
|
||||||
unsafe {
|
unsafe {
|
||||||
let idx = FT_Get_Char_Index(self.face, codepoint as FT_ULong);
|
let idx = FT_Get_Char_Index(self.face, codepoint as FT_ULong);
|
||||||
return if idx != 0 as FT_UInt {
|
if idx != 0 as FT_UInt {
|
||||||
Some(idx as GlyphId)
|
Some(idx as GlyphId)
|
||||||
} else {
|
} else {
|
||||||
debug!("Invalid codepoint: {}", codepoint);
|
debug!("Invalid codepoint: {}", codepoint);
|
||||||
None
|
None
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,10 +196,10 @@ impl FontHandleMethods for FontHandle {
|
||||||
let advance = (*slot).metrics.horiAdvance;
|
let advance = (*slot).metrics.horiAdvance;
|
||||||
debug!("h_advance for {} is {}", glyph, advance);
|
debug!("h_advance for {} is {}", glyph, advance);
|
||||||
let advance = advance as i32;
|
let advance = advance as i32;
|
||||||
return Some(fixed_to_float_ft(advance) as FractionalPixel);
|
Some(fixed_to_float_ft(advance) as FractionalPixel)
|
||||||
} else {
|
} else {
|
||||||
debug!("Unable to load glyph {}. reason: {}", glyph, res);
|
debug!("Unable to load glyph {}. reason: {}", glyph, res);
|
||||||
return None;
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,8 +239,7 @@ impl FontHandleMethods for FontHandle {
|
||||||
|
|
||||||
let average_advance = self.glyph_index('0')
|
let average_advance = self.glyph_index('0')
|
||||||
.and_then(|idx| self.glyph_h_advance(idx))
|
.and_then(|idx| self.glyph_h_advance(idx))
|
||||||
.map(|advance| self.font_units_to_au(advance))
|
.map_or(max_advance, |advance| self.font_units_to_au(advance));
|
||||||
.unwrap_or(max_advance);
|
|
||||||
|
|
||||||
let metrics = FontMetrics {
|
let metrics = FontMetrics {
|
||||||
underline_size: underline_size,
|
underline_size: underline_size,
|
||||||
|
@ -258,7 +257,7 @@ impl FontHandleMethods for FontHandle {
|
||||||
};
|
};
|
||||||
|
|
||||||
debug!("Font metrics (@{}px): {:?}", em_size.to_f32_px(), metrics);
|
debug!("Font metrics (@{}px): {:?}", em_size.to_f32_px(), metrics);
|
||||||
return metrics;
|
metrics
|
||||||
}
|
}
|
||||||
|
|
||||||
fn table_for_tag(&self, tag: FontTableTag) -> Option<Box<FontTable>> {
|
fn table_for_tag(&self, tag: FontTableTag) -> Option<Box<FontTable>> {
|
||||||
|
@ -310,6 +309,6 @@ impl<'a> FontHandle {
|
||||||
// If this isn't true then we're scaling one of the axes wrong
|
// If this isn't true then we're scaling one of the axes wrong
|
||||||
assert!(metrics.x_ppem == metrics.y_ppem);
|
assert!(metrics.x_ppem == metrics.y_ppem);
|
||||||
|
|
||||||
return Au::from_f64_px(value * x_scale);
|
Au::from_f64_px(value * x_scale)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1520,12 +1520,10 @@ impl BlockFlow {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn determine_if_layer_needed(&mut self) {
|
fn determine_if_layer_needed(&mut self) {
|
||||||
if self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) {
|
// Fixed position layers get layers.
|
||||||
// Fixed position layers get layers.
|
if self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) && self.is_fixed() {
|
||||||
if self.is_fixed() {
|
self.base.flags.insert(NEEDS_LAYER);
|
||||||
self.base.flags.insert(NEEDS_LAYER);
|
return
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This flow needs a layer if it has a 3d transform, or provides perspective
|
// This flow needs a layer if it has a 3d transform, or provides perspective
|
||||||
|
|
|
@ -1102,12 +1102,9 @@ impl<'a, 'ln, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<'ln>>
|
||||||
node,
|
node,
|
||||||
caption_side::T::top);
|
caption_side::T::top);
|
||||||
|
|
||||||
match construction_result {
|
if let ConstructionResult::Flow(table_flow, table_abs_descendants) = construction_result {
|
||||||
ConstructionResult::Flow(table_flow, table_abs_descendants) => {
|
wrapper_flow.add_new_child(table_flow);
|
||||||
wrapper_flow.add_new_child(table_flow);
|
abs_descendants.push_descendants(table_abs_descendants);
|
||||||
abs_descendants.push_descendants(table_abs_descendants);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the value of `caption-side` is `bottom`, place it now.
|
// If the value of `caption-side` is `bottom`, place it now.
|
||||||
|
@ -1271,12 +1268,9 @@ impl<'a, 'ln, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<'ln>>
|
||||||
for kid in node.children() {
|
for kid in node.children() {
|
||||||
// CSS 2.1 § 17.2.1. Treat all non-column child fragments of `table-column-group`
|
// CSS 2.1 § 17.2.1. Treat all non-column child fragments of `table-column-group`
|
||||||
// as `display: none`.
|
// as `display: none`.
|
||||||
match kid.swap_out_construction_result() {
|
if let ConstructionResult::ConstructionItem(ConstructionItem::TableColumnFragment(fragment))
|
||||||
ConstructionResult::ConstructionItem(ConstructionItem::TableColumnFragment(
|
= kid.swap_out_construction_result() {
|
||||||
fragment)) => {
|
col_fragments.push(fragment)
|
||||||
col_fragments.push(fragment);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if col_fragments.is_empty() {
|
if col_fragments.is_empty() {
|
||||||
|
|
|
@ -236,24 +236,20 @@ impl<'le, ConcreteElement> PrivateElementMatchMethods<'le, ConcreteElement>
|
||||||
let parent_data: Option<&PrivateStyleData> = unsafe {
|
let parent_data: Option<&PrivateStyleData> = unsafe {
|
||||||
parent_node.borrow_data_unchecked().map(|d| &*d)
|
parent_node.borrow_data_unchecked().map(|d| &*d)
|
||||||
};
|
};
|
||||||
match parent_data {
|
if let Some(parent_data_ref) = parent_data {
|
||||||
Some(parent_data_ref) => {
|
// Check parent style.
|
||||||
// Check parent style.
|
let parent_style = (*parent_data_ref).style.as_ref().unwrap();
|
||||||
let parent_style = (*parent_data_ref).style.as_ref().unwrap();
|
if !arc_ptr_eq(parent_style, &candidate.parent_style) {
|
||||||
if !arc_ptr_eq(parent_style, &candidate.parent_style) {
|
return None
|
||||||
return None
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check tag names, classes, etc.
|
|
||||||
if !candidate.can_share_style_with(self) {
|
|
||||||
return None
|
|
||||||
}
|
|
||||||
|
|
||||||
return Some(candidate.style.clone())
|
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Check tag names, classes, etc.
|
||||||
|
if !candidate.can_share_style_with(self) {
|
||||||
|
return None
|
||||||
|
}
|
||||||
|
|
||||||
|
return Some(candidate.style.clone())
|
||||||
|
}
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2006,24 +2006,18 @@ impl Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_late_computed_inline_position_if_necessary(&mut self) {
|
pub fn update_late_computed_inline_position_if_necessary(&mut self) {
|
||||||
match self.specific {
|
if let SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) = self.specific {
|
||||||
SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) => {
|
let position = self.border_box.start.i;
|
||||||
let position = self.border_box.start.i;
|
flow_ref::deref_mut(&mut info.flow_ref)
|
||||||
flow_ref::deref_mut(&mut info.flow_ref)
|
.update_late_computed_inline_position_if_necessary(position)
|
||||||
.update_late_computed_inline_position_if_necessary(position)
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_late_computed_block_position_if_necessary(&mut self) {
|
pub fn update_late_computed_block_position_if_necessary(&mut self) {
|
||||||
match self.specific {
|
if let SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) = self.specific {
|
||||||
SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) => {
|
let position = self.border_box.start.b;
|
||||||
let position = self.border_box.start.b;
|
flow_ref::deref_mut(&mut info.flow_ref)
|
||||||
flow_ref::deref_mut(&mut info.flow_ref)
|
.update_late_computed_block_position_if_necessary(position)
|
||||||
.update_late_computed_block_position_if_necessary(position)
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -302,9 +302,9 @@ impl<'a,'b> ResolveGeneratedContentFragmentMutator<'a,'b> {
|
||||||
"es.0[self.traversal.quote as usize]
|
"es.0[self.traversal.quote as usize]
|
||||||
};
|
};
|
||||||
if close {
|
if close {
|
||||||
close_quote.to_string()
|
close_quote.clone()
|
||||||
} else {
|
} else {
|
||||||
open_quote.to_string()
|
open_quote.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -654,7 +654,7 @@ impl LayoutTask {
|
||||||
// FIXME(njn): Just measuring the display tree for now.
|
// FIXME(njn): Just measuring the display tree for now.
|
||||||
let rw_data = possibly_locked_rw_data.lock();
|
let rw_data = possibly_locked_rw_data.lock();
|
||||||
let stacking_context = rw_data.stacking_context.as_ref();
|
let stacking_context = rw_data.stacking_context.as_ref();
|
||||||
let ref formatted_url = format!("url({})", *self.url.borrow());
|
let formatted_url = &format!("url({})", *self.url.borrow());
|
||||||
reports.push(Report {
|
reports.push(Report {
|
||||||
path: path![formatted_url, "layout-task", "display-list"],
|
path: path![formatted_url, "layout-task", "display-list"],
|
||||||
kind: ReportKind::ExplicitJemallocHeapSize,
|
kind: ReportKind::ExplicitJemallocHeapSize,
|
||||||
|
@ -731,7 +731,7 @@ impl LayoutTask {
|
||||||
|
|
||||||
/// Shuts down the layout task now. If there are any DOM nodes left, layout will now (safely)
|
/// Shuts down the layout task now. If there are any DOM nodes left, layout will now (safely)
|
||||||
/// crash.
|
/// crash.
|
||||||
fn exit_now<'a, 'b>(&mut self) {
|
fn exit_now(&mut self) {
|
||||||
if let Some(ref mut traversal) = self.parallel_traversal {
|
if let Some(ref mut traversal) = self.parallel_traversal {
|
||||||
traversal.shutdown()
|
traversal.shutdown()
|
||||||
}
|
}
|
||||||
|
|
|
@ -480,7 +480,7 @@ pub fn process_resolved_style_request<'ln, N: LayoutNode<'ln>>(
|
||||||
requested_node: N,
|
requested_node: N,
|
||||||
property: &Atom) -> Option<String> {
|
property: &Atom) -> Option<String> {
|
||||||
let maybe_data = layout_node.borrow_layout_data();
|
let maybe_data = layout_node.borrow_layout_data();
|
||||||
let position = maybe_data.map(|data| {
|
let position = maybe_data.map_or(Point2D::zero(), |data| {
|
||||||
match (*data).flow_construction_result {
|
match (*data).flow_construction_result {
|
||||||
ConstructionResult::Flow(ref flow_ref, _) =>
|
ConstructionResult::Flow(ref flow_ref, _) =>
|
||||||
flow::base(flow_ref.deref()).stacking_relative_position,
|
flow::base(flow_ref.deref()).stacking_relative_position,
|
||||||
|
@ -488,7 +488,7 @@ pub fn process_resolved_style_request<'ln, N: LayoutNode<'ln>>(
|
||||||
// https://github.com/servo/servo/issues/8307
|
// https://github.com/servo/servo/issues/8307
|
||||||
_ => Point2D::zero()
|
_ => Point2D::zero()
|
||||||
}
|
}
|
||||||
}).unwrap_or(Point2D::zero());
|
});
|
||||||
let property = match *property {
|
let property = match *property {
|
||||||
atom!("bottom") => PositionProperty::Bottom,
|
atom!("bottom") => PositionProperty::Bottom,
|
||||||
atom!("top") => PositionProperty::Top,
|
atom!("top") => PositionProperty::Top,
|
||||||
|
|
|
@ -747,33 +747,27 @@ fn set_inline_position_of_child_flow(
|
||||||
inline_start_border: border_collapse_info.collapsed_borders_for_row
|
inline_start_border: border_collapse_info.collapsed_borders_for_row
|
||||||
.inline
|
.inline
|
||||||
.get(child_index)
|
.get(child_index)
|
||||||
.map(|x| *x)
|
.map_or(CollapsedBorder::new(), |x| *x),
|
||||||
.unwrap_or(CollapsedBorder::new()),
|
|
||||||
inline_end_border: border_collapse_info.collapsed_borders_for_row
|
inline_end_border: border_collapse_info.collapsed_borders_for_row
|
||||||
.inline
|
.inline
|
||||||
.get(child_index + 1)
|
.get(child_index + 1)
|
||||||
.map(|x| *x)
|
.map_or(CollapsedBorder::new(), |x| *x),
|
||||||
.unwrap_or(CollapsedBorder::new()),
|
|
||||||
block_start_border: border_collapse_info.collapsed_borders_for_row
|
block_start_border: border_collapse_info.collapsed_borders_for_row
|
||||||
.block_start
|
.block_start
|
||||||
.get(child_index)
|
.get(child_index)
|
||||||
.map(|x| *x)
|
.map_or(CollapsedBorder::new(), |x| *x),
|
||||||
.unwrap_or(CollapsedBorder::new()),
|
|
||||||
block_end_border: border_collapse_info.collapsed_borders_for_row
|
block_end_border: border_collapse_info.collapsed_borders_for_row
|
||||||
.block_end
|
.block_end
|
||||||
.get(child_index)
|
.get(child_index)
|
||||||
.map(|x| *x)
|
.map_or(CollapsedBorder::new(), |x| *x),
|
||||||
.unwrap_or(CollapsedBorder::new()),
|
|
||||||
inline_start_width: border_collapse_info.collapsed_border_spacing_for_row
|
inline_start_width: border_collapse_info.collapsed_border_spacing_for_row
|
||||||
.inline
|
.inline
|
||||||
.get(child_index)
|
.get(child_index)
|
||||||
.map(|x| *x)
|
.map_or(Au(0), |x| *x),
|
||||||
.unwrap_or(Au(0)),
|
|
||||||
inline_end_width: border_collapse_info.collapsed_border_spacing_for_row
|
inline_end_width: border_collapse_info.collapsed_border_spacing_for_row
|
||||||
.inline
|
.inline
|
||||||
.get(child_index + 1)
|
.get(child_index + 1)
|
||||||
.map(|x| *x)
|
.map_or(Au(0), |x| *x),
|
||||||
.unwrap_or(Au(0)),
|
|
||||||
block_start_width: border_collapse_info.collapsed_border_spacing_for_row
|
block_start_width: border_collapse_info.collapsed_border_spacing_for_row
|
||||||
.block_start,
|
.block_start,
|
||||||
block_end_width: border_collapse_info.collapsed_border_spacing_for_row.block_end,
|
block_end_width: border_collapse_info.collapsed_border_spacing_for_row.block_end,
|
||||||
|
|
|
@ -38,15 +38,12 @@ fn text(fragments: &LinkedList<Fragment>) -> String {
|
||||||
let mut text = String::new();
|
let mut text = String::new();
|
||||||
|
|
||||||
for fragment in fragments {
|
for fragment in fragments {
|
||||||
match fragment.specific {
|
if let SpecificFragmentInfo::UnscannedText(ref info) = fragment.specific {
|
||||||
SpecificFragmentInfo::UnscannedText(ref info) => {
|
if fragment.white_space().preserve_newlines() {
|
||||||
if fragment.white_space().preserve_newlines() {
|
text.push_str(&info.text);
|
||||||
text.push_str(&info.text);
|
} else {
|
||||||
} else {
|
text.push_str(&info.text.replace("\n", " "));
|
||||||
text.push_str(&info.text.replace("\n", " "));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
text
|
text
|
||||||
|
|
|
@ -198,7 +198,7 @@ impl<'ln> TNode<'ln> for ServoLayoutNode<'ln> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_document(&self) -> Option<ServoLayoutDocument<'ln>> {
|
fn as_document(&self) -> Option<ServoLayoutDocument<'ln>> {
|
||||||
self.node.downcast().map(|document| ServoLayoutDocument::from_layout_js(document))
|
self.node.downcast().map(ServoLayoutDocument::from_layout_js)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_changed(&self) -> bool {
|
fn has_changed(&self) -> bool {
|
||||||
|
@ -432,7 +432,7 @@ impl<'le> ServoLayoutElement<'le> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_element<'le>(node: LayoutJS<Node>) -> Option<ServoLayoutElement<'le>> {
|
fn as_element<'le>(node: LayoutJS<Node>) -> Option<ServoLayoutElement<'le>> {
|
||||||
node.downcast().map(|element| ServoLayoutElement::from_layout_js(element))
|
node.downcast().map(ServoLayoutElement::from_layout_js)
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! state_getter {
|
macro_rules! state_getter {
|
||||||
|
|
|
@ -39,7 +39,7 @@ impl Cookie {
|
||||||
_ => (false, None)
|
_ => (false, None)
|
||||||
};
|
};
|
||||||
|
|
||||||
let url_host = request.host().map(|host| host.serialize()).unwrap_or("".to_owned());
|
let url_host = request.host().map_or("".to_owned(), |host| host.serialize());
|
||||||
|
|
||||||
// Step 4
|
// Step 4
|
||||||
let mut domain = cookie.domain.clone().unwrap_or("".to_owned());
|
let mut domain = cookie.domain.clone().unwrap_or("".to_owned());
|
||||||
|
|
|
@ -69,8 +69,8 @@ impl CookieStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cookie_comparator(a: &Cookie, b: &Cookie) -> Ordering {
|
pub fn cookie_comparator(a: &Cookie, b: &Cookie) -> Ordering {
|
||||||
let a_path_len = a.cookie.path.as_ref().map(|p| p.len()).unwrap_or(0);
|
let a_path_len = a.cookie.path.as_ref().map_or(0, |p| p.len());
|
||||||
let b_path_len = b.cookie.path.as_ref().map(|p| p.len()).unwrap_or(0);
|
let b_path_len = b.cookie.path.as_ref().map_or(0, |p| p.len());
|
||||||
match a_path_len.cmp(&b_path_len) {
|
match a_path_len.cmp(&b_path_len) {
|
||||||
Ordering::Equal => {
|
Ordering::Equal => {
|
||||||
let a_creation_time = a.creation_time.to_timespec();
|
let a_creation_time = a.creation_time.to_timespec();
|
||||||
|
|
|
@ -178,7 +178,7 @@ pub trait HttpResponse: Read {
|
||||||
fn status(&self) -> StatusCode;
|
fn status(&self) -> StatusCode;
|
||||||
fn status_raw(&self) -> &RawStatus;
|
fn status_raw(&self) -> &RawStatus;
|
||||||
fn http_version(&self) -> String {
|
fn http_version(&self) -> String {
|
||||||
return "HTTP/1.1".to_owned()
|
"HTTP/1.1".to_owned()
|
||||||
}
|
}
|
||||||
fn content_encoding(&self) -> Option<Encoding> {
|
fn content_encoding(&self) -> Option<Encoding> {
|
||||||
self.headers().get::<ContentEncoding>().and_then(|h| {
|
self.headers().get::<ContentEncoding>().and_then(|h| {
|
||||||
|
@ -295,11 +295,8 @@ impl HttpRequest for WrappedHttpRequest {
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(ref data) = *body {
|
if let Some(ref data) = *body {
|
||||||
match request_writer.write_all(&data) {
|
if let Err(e) = request_writer.write_all(&data) {
|
||||||
Err(e) => {
|
return Err(LoadError::Connection(url, e.description().to_owned()))
|
||||||
return Err(LoadError::Connection(url, e.description().to_owned()))
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,9 +61,9 @@ pub fn parse_hostsfile(hostsfile_content: &str) -> Box<HashMap<String, String>>
|
||||||
|
|
||||||
pub fn replace_hosts(url: &Url) -> Url {
|
pub fn replace_hosts(url: &Url) -> Url {
|
||||||
unsafe {
|
unsafe {
|
||||||
HOST_TABLE.map(|host_table| {
|
HOST_TABLE.map_or_else(|| url.clone(), |host_table| {
|
||||||
host_replacement(host_table, url)
|
host_replacement(host_table, url)
|
||||||
}).unwrap_or_else(|| url.clone())
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -649,8 +649,7 @@ mod system_reporter {
|
||||||
// Note that the sum of all these segments' RSS values differs from the "resident"
|
// Note that the sum of all these segments' RSS values differs from the "resident"
|
||||||
// measurement obtained via /proc/<pid>/statm in resident(). It's unclear why this
|
// measurement obtained via /proc/<pid>/statm in resident(). It's unclear why this
|
||||||
// difference occurs; for some processes the measurements match, but for Servo they do not.
|
// difference occurs; for some processes the measurements match, but for Servo they do not.
|
||||||
let segs: Vec<(String, usize)> = seg_map.into_iter().collect();
|
seg_map.into_iter().collect()
|
||||||
segs
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "linux"))]
|
#[cfg(not(target_os = "linux"))]
|
||||||
|
|
|
@ -172,9 +172,10 @@ impl Profiler {
|
||||||
let mut start_energy = read_energy_uj();
|
let mut start_energy = read_energy_uj();
|
||||||
loop {
|
loop {
|
||||||
for _ in 0..loop_count {
|
for _ in 0..loop_count {
|
||||||
match run_ap_thread() {
|
if run_ap_thread() {
|
||||||
true => thread::sleep(Duration::from_millis(SLEEP_MS as u64)),
|
thread::sleep(Duration::from_millis(SLEEP_MS as u64))
|
||||||
false => return,
|
} else {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let end_time = precise_time_ns();
|
let end_time = precise_time_ns();
|
||||||
|
@ -258,7 +259,7 @@ impl Profiler {
|
||||||
let data_len = data.len();
|
let data_len = data.len();
|
||||||
if data_len > 0 {
|
if data_len > 0 {
|
||||||
let (mean, median, min, max) =
|
let (mean, median, min, max) =
|
||||||
(data.iter().map(|&x|x).sum::<f64>() / (data_len as f64),
|
(data.iter().sum::<f64>() / (data_len as f64),
|
||||||
data[data_len / 2],
|
data[data_len / 2],
|
||||||
data.iter().fold(f64::INFINITY, |a, &b| a.min(b)),
|
data.iter().fold(f64::INFINITY, |a, &b| a.min(b)),
|
||||||
data.iter().fold(-f64::INFINITY, |a, &b| a.max(b)));
|
data.iter().fold(-f64::INFINITY, |a, &b| a.max(b)));
|
||||||
|
|
|
@ -92,10 +92,9 @@ impl CORSRequest {
|
||||||
method: Method,
|
method: Method,
|
||||||
headers: Headers)
|
headers: Headers)
|
||||||
-> CORSRequest {
|
-> CORSRequest {
|
||||||
match referer.scheme_data {
|
if let SchemeData::Relative(ref mut data) = referer.scheme_data {
|
||||||
SchemeData::Relative(ref mut data) => data.path = vec![],
|
data.path = vec![];
|
||||||
_ => {}
|
}
|
||||||
};
|
|
||||||
referer.fragment = None;
|
referer.fragment = None;
|
||||||
referer.query = None;
|
referer.query = None;
|
||||||
CORSRequest {
|
CORSRequest {
|
||||||
|
@ -167,12 +166,11 @@ impl CORSRequest {
|
||||||
let cache = &mut CORSCache(vec!()); // XXXManishearth Should come from user agent
|
let cache = &mut CORSCache(vec!()); // XXXManishearth Should come from user agent
|
||||||
if self.preflight_flag &&
|
if self.preflight_flag &&
|
||||||
!cache.match_method(self, &self.method) &&
|
!cache.match_method(self, &self.method) &&
|
||||||
!self.headers.iter().all(|h| is_simple_header(&h) && cache.match_header(self, h.name())) {
|
!self.headers.iter().all(|h| is_simple_header(&h) && cache.match_header(self, h.name())) &&
|
||||||
if !is_simple_method(&self.method) || self.mode == RequestMode::ForcedPreflight {
|
(!is_simple_method(&self.method) || self.mode == RequestMode::ForcedPreflight) {
|
||||||
return self.preflight_fetch();
|
return self.preflight_fetch();
|
||||||
// Everything after this is part of XHR::fetch()
|
// Everything after this is part of XHR::fetch()
|
||||||
// Expect the organization of code to improve once we have a fetch crate
|
// Expect the organization of code to improve once we have a fetch crate
|
||||||
}
|
|
||||||
}
|
}
|
||||||
response
|
response
|
||||||
}
|
}
|
||||||
|
@ -398,12 +396,11 @@ impl CORSCache {
|
||||||
self.cleanup();
|
self.cleanup();
|
||||||
let CORSCache(ref mut buf) = *self;
|
let CORSCache(ref mut buf) = *self;
|
||||||
// Credentials are not yet implemented here
|
// Credentials are not yet implemented here
|
||||||
let entry = buf.iter_mut().find(|e| {
|
buf.iter_mut().find(|e| {
|
||||||
e.origin.scheme == request.origin.scheme && e.origin.host() == request.origin.host() &&
|
e.origin.scheme == request.origin.scheme && e.origin.host() == request.origin.host() &&
|
||||||
e.origin.port() == request.origin.port() && e.url == request.destination &&
|
e.origin.port() == request.origin.port() && e.url == request.destination &&
|
||||||
e.header_or_method.match_header(header_name)
|
e.header_or_method.match_header(header_name)
|
||||||
});
|
})
|
||||||
entry
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn match_header(&mut self, request: &CORSRequest, header_name: &str) -> bool {
|
fn match_header(&mut self, request: &CORSRequest, header_name: &str) -> bool {
|
||||||
|
@ -426,12 +423,11 @@ impl CORSCache {
|
||||||
self.cleanup();
|
self.cleanup();
|
||||||
let CORSCache(ref mut buf) = *self;
|
let CORSCache(ref mut buf) = *self;
|
||||||
// Credentials are not yet implemented here
|
// Credentials are not yet implemented here
|
||||||
let entry = buf.iter_mut().find(|e| {
|
buf.iter_mut().find(|e| {
|
||||||
e.origin.scheme == request.origin.scheme && e.origin.host() == request.origin.host() &&
|
e.origin.scheme == request.origin.scheme && e.origin.host() == request.origin.host() &&
|
||||||
e.origin.port() == request.origin.port() && e.url == request.destination &&
|
e.origin.port() == request.origin.port() && e.url == request.destination &&
|
||||||
e.header_or_method.match_method(method)
|
e.header_or_method.match_method(method)
|
||||||
});
|
})
|
||||||
entry
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://fetch.spec.whatwg.org/#concept-cache-match-method
|
/// https://fetch.spec.whatwg.org/#concept-cache-match-method
|
||||||
|
|
|
@ -191,7 +191,7 @@ impl Attr {
|
||||||
/// Sets the owner element. Should be called after the attribute is added
|
/// Sets the owner element. Should be called after the attribute is added
|
||||||
/// or removed from its older parent.
|
/// or removed from its older parent.
|
||||||
pub fn set_owner(&self, owner: Option<&Element>) {
|
pub fn set_owner(&self, owner: Option<&Element>) {
|
||||||
let ref ns = self.identifier.namespace;
|
let ns = &self.identifier.namespace;
|
||||||
match (self.owner().r(), owner) {
|
match (self.owner().r(), owner) {
|
||||||
(None, Some(new)) => {
|
(None, Some(new)) => {
|
||||||
// Already in the list of attributes of new owner.
|
// Already in the list of attributes of new owner.
|
||||||
|
|
|
@ -486,7 +486,7 @@ impl RootCollection {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Start tracking a stack-based root
|
/// Start tracking a stack-based root
|
||||||
fn root<'b>(&self, untracked_reflector: *const Reflector) {
|
fn root(&self, untracked_reflector: *const Reflector) {
|
||||||
debug_assert!(task_state::get().is_script());
|
debug_assert!(task_state::get().is_script());
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut roots = &mut *self.roots.get();
|
let mut roots = &mut *self.roots.get();
|
||||||
|
@ -496,7 +496,7 @@ impl RootCollection {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stop tracking a stack-based root, asserting if the reflector isn't found
|
/// Stop tracking a stack-based root, asserting if the reflector isn't found
|
||||||
fn unroot<'b, T: Reflectable>(&self, rooted: &Root<T>) {
|
fn unroot<T: Reflectable>(&self, rooted: &Root<T>) {
|
||||||
debug_assert!(task_state::get().is_script());
|
debug_assert!(task_state::get().is_script());
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut roots = &mut *self.roots.get();
|
let mut roots = &mut *self.roots.get();
|
||||||
|
|
|
@ -148,9 +148,10 @@ pub fn xml_name_type(name: &str) -> XMLName {
|
||||||
return XMLName::InvalidXMLName;
|
return XMLName::InvalidXMLName;
|
||||||
}
|
}
|
||||||
if c == ':' {
|
if c == ':' {
|
||||||
match seen_colon {
|
if seen_colon {
|
||||||
true => non_qname_colons = true,
|
non_qname_colons = true;
|
||||||
false => seen_colon = true,
|
} else {
|
||||||
|
seen_colon = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
last = c
|
last = c
|
||||||
|
@ -160,9 +161,10 @@ pub fn xml_name_type(name: &str) -> XMLName {
|
||||||
non_qname_colons = true
|
non_qname_colons = true
|
||||||
}
|
}
|
||||||
|
|
||||||
match non_qname_colons {
|
if non_qname_colons {
|
||||||
false => XMLName::QName,
|
XMLName::Name
|
||||||
true => XMLName::Name,
|
} else {
|
||||||
|
XMLName::QName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -320,10 +320,8 @@ impl CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if result.is_ok() {
|
if result.is_ok() && !self.is_origin_clean(image) {
|
||||||
if !self.is_origin_clean(image) {
|
self.set_origin_unclean()
|
||||||
self.set_origin_unclean()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
result.map(DOMString::from).unwrap_or(DOMString::new())
|
result.map_or(DOMString::new(), DOMString::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertyvalue
|
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertyvalue
|
||||||
|
@ -175,11 +175,10 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 3 & 4
|
// Step 3 & 4
|
||||||
let result = match owner.get_inline_style_declaration(&property) {
|
match owner.get_inline_style_declaration(&property) {
|
||||||
Some(declaration) => DOMString::from(declaration.value()),
|
Some(declaration) => DOMString::from(declaration.value()),
|
||||||
None => DOMString::new(),
|
None => DOMString::new(),
|
||||||
};
|
}
|
||||||
result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertypriority
|
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertypriority
|
||||||
|
|
|
@ -1926,9 +1926,10 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
let clone_children = match deep {
|
let clone_children = if deep {
|
||||||
true => CloneChildrenFlag::CloneChildren,
|
CloneChildrenFlag::CloneChildren
|
||||||
false => CloneChildrenFlag::DoNotCloneChildren,
|
} else {
|
||||||
|
CloneChildrenFlag::DoNotCloneChildren
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Node::clone(node, Some(self), clone_children))
|
Ok(Node::clone(node, Some(self), clone_children))
|
||||||
|
@ -2325,7 +2326,7 @@ impl DocumentMethods for Document {
|
||||||
let (tx, rx) = ipc::channel().unwrap();
|
let (tx, rx) = ipc::channel().unwrap();
|
||||||
let _ = self.window.resource_task().send(GetCookiesForUrl((*url).clone(), tx, NonHTTP));
|
let _ = self.window.resource_task().send(GetCookiesForUrl((*url).clone(), tx, NonHTTP));
|
||||||
let cookies = rx.recv().unwrap();
|
let cookies = rx.recv().unwrap();
|
||||||
Ok(cookies.map(DOMString::from).unwrap_or(DOMString::from("")))
|
Ok(cookies.map_or(DOMString::new(), DOMString::from))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-cookie
|
// https://html.spec.whatwg.org/multipage/#dom-document-cookie
|
||||||
|
|
|
@ -54,10 +54,10 @@ impl DOMTokenList {
|
||||||
impl DOMTokenListMethods for DOMTokenList {
|
impl DOMTokenListMethods for DOMTokenList {
|
||||||
// https://dom.spec.whatwg.org/#dom-domtokenlist-length
|
// https://dom.spec.whatwg.org/#dom-domtokenlist-length
|
||||||
fn Length(&self) -> u32 {
|
fn Length(&self) -> u32 {
|
||||||
self.attribute().map(|attr| {
|
self.attribute().map_or(0, |attr| {
|
||||||
let attr = attr.r();
|
let attr = attr.r();
|
||||||
attr.value().as_tokens().len()
|
attr.value().as_tokens().len()
|
||||||
}).unwrap_or(0) as u32
|
}) as u32
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-domtokenlist-item
|
// https://dom.spec.whatwg.org/#dom-domtokenlist-item
|
||||||
|
@ -71,13 +71,13 @@ impl DOMTokenListMethods for DOMTokenList {
|
||||||
// https://dom.spec.whatwg.org/#dom-domtokenlist-contains
|
// https://dom.spec.whatwg.org/#dom-domtokenlist-contains
|
||||||
fn Contains(&self, token: DOMString) -> Fallible<bool> {
|
fn Contains(&self, token: DOMString) -> Fallible<bool> {
|
||||||
self.check_token_exceptions(&token).map(|token| {
|
self.check_token_exceptions(&token).map(|token| {
|
||||||
self.attribute().map(|attr| {
|
self.attribute().map_or(false, |attr| {
|
||||||
let attr = attr.r();
|
let attr = attr.r();
|
||||||
attr.value()
|
attr.value()
|
||||||
.as_tokens()
|
.as_tokens()
|
||||||
.iter()
|
.iter()
|
||||||
.any(|atom: &Atom| *atom == token)
|
.any(|atom: &Atom| *atom == token)
|
||||||
}).unwrap_or(false)
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -924,9 +924,8 @@ impl Element {
|
||||||
// https://html.spec.whatwg.org/multipage/#attr-data-*
|
// https://html.spec.whatwg.org/multipage/#attr-data-*
|
||||||
pub fn set_custom_attribute(&self, name: DOMString, value: DOMString) -> ErrorResult {
|
pub fn set_custom_attribute(&self, name: DOMString, value: DOMString) -> ErrorResult {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
match xml_name_type(&name) {
|
if let InvalidXMLName = xml_name_type(&name) {
|
||||||
InvalidXMLName => return Err(Error::InvalidCharacter),
|
return Err(Error::InvalidCharacter);
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Steps 2-5.
|
// Steps 2-5.
|
||||||
|
@ -1012,8 +1011,7 @@ impl Element {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
self.get_attribute(&ns!(), &atom!("class"))
|
self.get_attribute(&ns!(), &atom!("class"))
|
||||||
.map(|attr| attr.value().as_tokens().iter().any(|atom| is_equal(name, atom)))
|
.map_or(false, |attr| attr.value().as_tokens().iter().any(|atom| is_equal(name, atom)))
|
||||||
.unwrap_or(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_atomic_attribute(&self, local_name: &Atom, value: DOMString) {
|
pub fn set_atomic_attribute(&self, local_name: &Atom, value: DOMString) {
|
||||||
|
@ -1884,10 +1882,11 @@ impl Element {
|
||||||
}
|
}
|
||||||
let node = self.upcast::<Node>();
|
let node = self.upcast::<Node>();
|
||||||
node.owner_doc().element_state_will_change(self);
|
node.owner_doc().element_state_will_change(self);
|
||||||
match value {
|
if value {
|
||||||
true => state.insert(which),
|
state.insert(which);
|
||||||
false => state.remove(which),
|
} else {
|
||||||
};
|
state.remove(which);
|
||||||
|
}
|
||||||
self.state.set(state);
|
self.state.set(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -355,24 +355,21 @@ impl EventTargetMethods for EventTarget {
|
||||||
ty: DOMString,
|
ty: DOMString,
|
||||||
listener: Option<Rc<EventListener>>,
|
listener: Option<Rc<EventListener>>,
|
||||||
capture: bool) {
|
capture: bool) {
|
||||||
match listener {
|
if let Some(listener) = listener {
|
||||||
Some(listener) => {
|
let mut handlers = self.handlers.borrow_mut();
|
||||||
let mut handlers = self.handlers.borrow_mut();
|
let entry = match handlers.entry(Atom::from(&*ty)) {
|
||||||
let entry = match handlers.entry(Atom::from(&*ty)) {
|
Occupied(entry) => entry.into_mut(),
|
||||||
Occupied(entry) => entry.into_mut(),
|
Vacant(entry) => entry.insert(vec!()),
|
||||||
Vacant(entry) => entry.insert(vec!()),
|
};
|
||||||
};
|
|
||||||
|
|
||||||
let phase = if capture { ListenerPhase::Capturing } else { ListenerPhase::Bubbling };
|
let phase = if capture { ListenerPhase::Capturing } else { ListenerPhase::Bubbling };
|
||||||
let new_entry = EventListenerEntry {
|
let new_entry = EventListenerEntry {
|
||||||
phase: phase,
|
phase: phase,
|
||||||
listener: EventListenerType::Additive(listener)
|
listener: EventListenerType::Additive(listener)
|
||||||
};
|
};
|
||||||
if !entry.contains(&new_entry) {
|
if !entry.contains(&new_entry) {
|
||||||
entry.push(new_entry);
|
entry.push(new_entry);
|
||||||
}
|
}
|
||||||
},
|
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,22 +378,19 @@ impl EventTargetMethods for EventTarget {
|
||||||
ty: DOMString,
|
ty: DOMString,
|
||||||
listener: Option<Rc<EventListener>>,
|
listener: Option<Rc<EventListener>>,
|
||||||
capture: bool) {
|
capture: bool) {
|
||||||
match listener {
|
if let Some(ref listener) = listener {
|
||||||
Some(ref listener) => {
|
let mut handlers = self.handlers.borrow_mut();
|
||||||
let mut handlers = self.handlers.borrow_mut();
|
let entry = handlers.get_mut(&Atom::from(&*ty));
|
||||||
let entry = handlers.get_mut(&Atom::from(&*ty));
|
for entry in entry {
|
||||||
for entry in entry {
|
let phase = if capture { ListenerPhase::Capturing } else { ListenerPhase::Bubbling };
|
||||||
let phase = if capture { ListenerPhase::Capturing } else { ListenerPhase::Bubbling };
|
let old_entry = EventListenerEntry {
|
||||||
let old_entry = EventListenerEntry {
|
phase: phase,
|
||||||
phase: phase,
|
listener: EventListenerType::Additive(listener.clone())
|
||||||
listener: EventListenerType::Additive(listener.clone())
|
};
|
||||||
};
|
if let Some(position) = entry.iter().position(|e| *e == old_entry) {
|
||||||
if let Some(position) = entry.iter().position(|e| *e == old_entry) {
|
entry.remove(position);
|
||||||
entry.remove(position);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -287,8 +287,8 @@ impl<'a> Iterator for HTMLCollectionElementsIter<'a> {
|
||||||
type Item = Root<Element>;
|
type Item = Root<Element>;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
let ref filter = self.filter;
|
let filter = &self.filter;
|
||||||
let ref root = self.root;
|
let root = &self.root;
|
||||||
self.node_iter.by_ref()
|
self.node_iter.by_ref()
|
||||||
.filter_map(Root::downcast)
|
.filter_map(Root::downcast)
|
||||||
.filter(|element| filter.filter(&element, root))
|
.filter(|element| filter.filter(&element, root))
|
||||||
|
@ -306,8 +306,8 @@ impl<'a> Iterator for HTMLCollectionElementsRevIter<'a> {
|
||||||
type Item = Root<Element>;
|
type Item = Root<Element>;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
let ref filter = self.filter;
|
let filter = &self.filter;
|
||||||
let ref root = self.root;
|
let root = &self.root;
|
||||||
self.node_iter.by_ref()
|
self.node_iter.by_ref()
|
||||||
.filter_map(Root::downcast)
|
.filter_map(Root::downcast)
|
||||||
.filter(|element| filter.filter(&element, root))
|
.filter(|element| filter.filter(&element, root))
|
||||||
|
|
|
@ -307,40 +307,37 @@ impl HTMLFormElement {
|
||||||
.any(|a| Root::downcast::<HTMLDataListElement>(a).is_some()) {
|
.any(|a| Root::downcast::<HTMLDataListElement>(a).is_some()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
match child.type_id() {
|
if let NodeTypeId::Element(ElementTypeId::HTMLElement(element)) = child.type_id() {
|
||||||
NodeTypeId::Element(ElementTypeId::HTMLElement(element)) => {
|
match element {
|
||||||
match element {
|
HTMLElementTypeId::HTMLInputElement => {
|
||||||
HTMLElementTypeId::HTMLInputElement => {
|
let input = child.downcast::<HTMLInputElement>().unwrap();
|
||||||
let input = child.downcast::<HTMLInputElement>().unwrap();
|
// Step 3.2-3.7
|
||||||
// Step 3.2-3.7
|
if let Some(datum) = input.get_form_datum(submitter) {
|
||||||
if let Some(datum) = input.get_form_datum(submitter) {
|
data_set.push(datum);
|
||||||
data_set.push(datum);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
HTMLElementTypeId::HTMLButtonElement |
|
|
||||||
HTMLElementTypeId::HTMLObjectElement => {
|
|
||||||
// Unimplemented
|
|
||||||
()
|
|
||||||
}
|
|
||||||
HTMLElementTypeId::HTMLSelectElement => {
|
|
||||||
let select = child.downcast::<HTMLSelectElement>().unwrap();
|
|
||||||
select.push_form_data(&mut data_set);
|
|
||||||
}
|
|
||||||
HTMLElementTypeId::HTMLTextAreaElement => {
|
|
||||||
let textarea = child.downcast::<HTMLTextAreaElement>().unwrap();
|
|
||||||
let name = textarea.Name();
|
|
||||||
if !name.is_empty() {
|
|
||||||
data_set.push(FormDatum {
|
|
||||||
ty: textarea.Type(),
|
|
||||||
name: name,
|
|
||||||
value: textarea.Value()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
HTMLElementTypeId::HTMLButtonElement |
|
||||||
|
HTMLElementTypeId::HTMLObjectElement => {
|
||||||
|
// Unimplemented
|
||||||
|
()
|
||||||
|
}
|
||||||
|
HTMLElementTypeId::HTMLSelectElement => {
|
||||||
|
let select = child.downcast::<HTMLSelectElement>().unwrap();
|
||||||
|
select.push_form_data(&mut data_set);
|
||||||
|
}
|
||||||
|
HTMLElementTypeId::HTMLTextAreaElement => {
|
||||||
|
let textarea = child.downcast::<HTMLTextAreaElement>().unwrap();
|
||||||
|
let name = textarea.Name();
|
||||||
|
if !name.is_empty() {
|
||||||
|
data_set.push(FormDatum {
|
||||||
|
ty: textarea.Type(),
|
||||||
|
name: name,
|
||||||
|
value: textarea.Value()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => ()
|
||||||
}
|
}
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data_set
|
data_set
|
||||||
|
@ -603,14 +600,11 @@ pub trait FormControl: DerivedFrom<Element> + Reflectable {
|
||||||
if !owner.is_empty() {
|
if !owner.is_empty() {
|
||||||
let doc = document_from_node(elem);
|
let doc = document_from_node(elem);
|
||||||
let owner = doc.GetElementById(owner);
|
let owner = doc.GetElementById(owner);
|
||||||
match owner {
|
if let Some(ref o) = owner {
|
||||||
Some(ref o) => {
|
let maybe_form = o.downcast::<HTMLFormElement>();
|
||||||
let maybe_form = o.downcast::<HTMLFormElement>();
|
if maybe_form.is_some() {
|
||||||
if maybe_form.is_some() {
|
return maybe_form.map(Root::from_ref);
|
||||||
return maybe_form.map(Root::from_ref);
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elem.upcast::<Node>().ancestors().filter_map(Root::downcast).next()
|
elem.upcast::<Node>().ancestors().filter_map(Root::downcast).next()
|
||||||
|
|
|
@ -596,7 +596,7 @@ impl VirtualMethods for HTMLInputElement {
|
||||||
&atom!("value") if !self.value_changed.get() => {
|
&atom!("value") if !self.value_changed.get() => {
|
||||||
let value = mutation.new_value(attr).map(|value| (**value).to_owned());
|
let value = mutation.new_value(attr).map(|value| (**value).to_owned());
|
||||||
self.textinput.borrow_mut().set_content(
|
self.textinput.borrow_mut().set_content(
|
||||||
value.map(DOMString::from).unwrap_or(DOMString::from("")));
|
value.map_or(DOMString::new(), DOMString::from));
|
||||||
},
|
},
|
||||||
&atom!("name") if self.input_type.get() == InputType::InputRadio => {
|
&atom!("name") if self.input_type.get() == InputType::InputRadio => {
|
||||||
self.radio_group_updated(
|
self.radio_group_updated(
|
||||||
|
@ -663,9 +663,8 @@ impl VirtualMethods for HTMLInputElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
if event.type_() == atom!("click") && !event.DefaultPrevented() {
|
if event.type_() == atom!("click") && !event.DefaultPrevented() {
|
||||||
match self.input_type.get() {
|
if let InputType::InputRadio = self.input_type.get() {
|
||||||
InputType::InputRadio => self.update_checked_state(true, true),
|
self.update_checked_state(true, true);
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Dispatch events for non activatable inputs
|
// TODO: Dispatch events for non activatable inputs
|
||||||
|
|
|
@ -49,7 +49,7 @@ impl Activatable for HTMLLabelElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_instance_activatable(&self) -> bool {
|
fn is_instance_activatable(&self) -> bool {
|
||||||
return true;
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#run-pre-click-activation-steps
|
// https://html.spec.whatwg.org/multipage/#run-pre-click-activation-steps
|
||||||
|
|
|
@ -53,9 +53,8 @@ impl HTMLMetaElement {
|
||||||
let name = name.value().to_ascii_lowercase();
|
let name = name.value().to_ascii_lowercase();
|
||||||
let name = name.trim_matches(HTML_SPACE_CHARACTERS);
|
let name = name.trim_matches(HTML_SPACE_CHARACTERS);
|
||||||
|
|
||||||
match name {
|
if name == "viewport" {
|
||||||
"viewport" => self.apply_viewport(),
|
self.apply_viewport();
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,7 +287,7 @@ impl HTMLScriptElement {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let (action_sender, action_receiver) = ipc::channel().unwrap();
|
let (action_sender, action_receiver) = ipc::channel().unwrap();
|
||||||
let listener = box NetworkListener {
|
let listener = NetworkListener {
|
||||||
context: context,
|
context: context,
|
||||||
script_chan: script_chan,
|
script_chan: script_chan,
|
||||||
};
|
};
|
||||||
|
@ -354,7 +354,7 @@ impl HTMLScriptElement {
|
||||||
parser.r().suspend();
|
parser.r().suspend();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NextParserState::Suspend;
|
NextParserState::Suspend
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_ready_to_be_executed(&self) -> bool {
|
pub fn is_ready_to_be_executed(&self) -> bool {
|
||||||
|
|
|
@ -72,7 +72,7 @@ impl HTMLTableCellElementMethods for HTMLTableCellElement {
|
||||||
|
|
||||||
parent_children.filter(|c| c.is::<HTMLTableCellElement>())
|
parent_children.filter(|c| c.is::<HTMLTableCellElement>())
|
||||||
.position(|c| c.r() == self_node)
|
.position(|c| c.r() == self_node)
|
||||||
.map(|p| p as i32).unwrap_or(-1)
|
.map_or(-1, |p| p as i32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,8 +73,7 @@ impl LayoutHTMLTextAreaElementHelpers for LayoutJS<HTMLTextAreaElement> {
|
||||||
unsafe {
|
unsafe {
|
||||||
(*self.upcast::<Element>().unsafe_get())
|
(*self.upcast::<Element>().unsafe_get())
|
||||||
.get_attr_for_layout(&ns!(), &atom!("cols"))
|
.get_attr_for_layout(&ns!(), &atom!("cols"))
|
||||||
.map(AttrValue::as_uint)
|
.map_or(DEFAULT_COLS, AttrValue::as_uint)
|
||||||
.unwrap_or(DEFAULT_COLS)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,8 +82,7 @@ impl LayoutHTMLTextAreaElementHelpers for LayoutJS<HTMLTextAreaElement> {
|
||||||
unsafe {
|
unsafe {
|
||||||
(*self.upcast::<Element>().unsafe_get())
|
(*self.upcast::<Element>().unsafe_get())
|
||||||
.get_attr_for_layout(&ns!(), &atom!("rows"))
|
.get_attr_for_layout(&ns!(), &atom!("rows"))
|
||||||
.map(AttrValue::as_uint)
|
.map_or(DEFAULT_ROWS, AttrValue::as_uint)
|
||||||
.unwrap_or(DEFAULT_ROWS)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -768,7 +768,7 @@ impl Node {
|
||||||
NodeInfo {
|
NodeInfo {
|
||||||
uniqueId: self.get_unique_id(),
|
uniqueId: self.get_unique_id(),
|
||||||
baseURI: String::from(self.BaseURI()),
|
baseURI: String::from(self.BaseURI()),
|
||||||
parent: self.GetParentNode().map(|node| node.get_unique_id()).unwrap_or("".to_owned()),
|
parent: self.GetParentNode().map_or("".to_owned(), |node| node.get_unique_id()),
|
||||||
nodeType: self.NodeType(),
|
nodeType: self.NodeType(),
|
||||||
namespaceURI: String::new(), //FIXME
|
namespaceURI: String::new(), //FIXME
|
||||||
nodeName: String::from(self.NodeName()),
|
nodeName: String::from(self.NodeName()),
|
||||||
|
@ -783,8 +783,7 @@ impl Node {
|
||||||
isDocumentElement:
|
isDocumentElement:
|
||||||
self.owner_doc()
|
self.owner_doc()
|
||||||
.GetDocumentElement()
|
.GetDocumentElement()
|
||||||
.map(|elem| elem.upcast::<Node>() == self)
|
.map_or(false, |elem| elem.upcast::<Node>() == self),
|
||||||
.unwrap_or(false),
|
|
||||||
|
|
||||||
shortValue: self.GetNodeValue().map(String::from).unwrap_or_default(), //FIXME: truncate
|
shortValue: self.GetNodeValue().map(String::from).unwrap_or_default(), //FIXME: truncate
|
||||||
incompleteValue: false, //FIXME: reflect truncation
|
incompleteValue: false, //FIXME: reflect truncation
|
||||||
|
@ -1602,9 +1601,10 @@ impl Node {
|
||||||
},
|
},
|
||||||
NodeTypeId::Document(_) => {
|
NodeTypeId::Document(_) => {
|
||||||
let document = node.downcast::<Document>().unwrap();
|
let document = node.downcast::<Document>().unwrap();
|
||||||
let is_html_doc = match document.is_html_document() {
|
let is_html_doc = if document.is_html_document() {
|
||||||
true => IsHTMLDocument::HTMLDocument,
|
IsHTMLDocument::HTMLDocument
|
||||||
false => IsHTMLDocument::NonHTMLDocument,
|
} else {
|
||||||
|
IsHTMLDocument::NonHTMLDocument
|
||||||
};
|
};
|
||||||
let window = document.window();
|
let window = document.window();
|
||||||
let loader = DocumentLoader::new(&*document.loader());
|
let loader = DocumentLoader::new(&*document.loader());
|
||||||
|
@ -2435,8 +2435,7 @@ impl<'a> UnbindContext<'a> {
|
||||||
if let Some(index) = self.index.get() {
|
if let Some(index) = self.index.get() {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
let index =
|
let index = self.prev_sibling.map_or(0, |sibling| sibling.index() + 1);
|
||||||
self.prev_sibling.map(|sibling| sibling.index() + 1).unwrap_or(0);
|
|
||||||
self.index.set(Some(index));
|
self.index.set(Some(index));
|
||||||
index
|
index
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ pub fn load_script(head: &HTMLHeadElement) {
|
||||||
PathBuf::from(path_str)
|
PathBuf::from(path_str)
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut files = read_dir(&path).ok().expect("Bad path passed to --userscripts")
|
let mut files = read_dir(&path).expect("Bad path passed to --userscripts")
|
||||||
.filter_map(|e| e.ok())
|
.filter_map(|e| e.ok())
|
||||||
.map(|e| e.path()).collect::<Vec<_>>();
|
.map(|e| e.path()).collect::<Vec<_>>();
|
||||||
|
|
||||||
|
|
|
@ -323,7 +323,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn css_error_reporter(&self) -> Box<ParseErrorReporter + Send> {
|
pub fn css_error_reporter(&self) -> Box<ParseErrorReporter + Send> {
|
||||||
return self.error_reporter.clone();
|
self.error_reporter.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -782,9 +782,7 @@ impl WindowMethods for Window {
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom-view/#dom-window-devicepixelratio
|
// https://drafts.csswg.org/cssom-view/#dom-window-devicepixelratio
|
||||||
fn DevicePixelRatio(&self) -> Finite<f64> {
|
fn DevicePixelRatio(&self) -> Finite<f64> {
|
||||||
let dpr = self.window_size.get()
|
let dpr = self.window_size.get().map_or(1.0f32, |data| data.device_pixel_ratio.get());
|
||||||
.map(|data| data.device_pixel_ratio.get())
|
|
||||||
.unwrap_or(1.0f32);
|
|
||||||
Finite::wrap(dpr as f64)
|
Finite::wrap(dpr as f64)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -904,10 +902,10 @@ impl Window {
|
||||||
let point = Point2D::new(x, y);
|
let point = Point2D::new(x, y);
|
||||||
let smooth = match behavior {
|
let smooth = match behavior {
|
||||||
ScrollBehavior::Auto => {
|
ScrollBehavior::Auto => {
|
||||||
element.map(|_element| {
|
element.map_or(false, |_element| {
|
||||||
// TODO check computed scroll-behaviour CSS property
|
// TODO check computed scroll-behaviour CSS property
|
||||||
true
|
true
|
||||||
}).unwrap_or(false)
|
})
|
||||||
}
|
}
|
||||||
ScrollBehavior::Instant => false,
|
ScrollBehavior::Instant => false,
|
||||||
ScrollBehavior::Smooth => true
|
ScrollBehavior::Smooth => true
|
||||||
|
|
|
@ -271,7 +271,7 @@ impl XMLHttpRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
let (action_sender, action_receiver) = ipc::channel().unwrap();
|
let (action_sender, action_receiver) = ipc::channel().unwrap();
|
||||||
let listener = box NetworkListener {
|
let listener = NetworkListener {
|
||||||
context: context,
|
context: context,
|
||||||
script_chan: script_chan,
|
script_chan: script_chan,
|
||||||
};
|
};
|
||||||
|
@ -483,7 +483,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
||||||
_ => data
|
_ => data
|
||||||
};
|
};
|
||||||
let extracted = data.as_ref().map(|d| d.extract());
|
let extracted = data.as_ref().map(|d| d.extract());
|
||||||
self.request_body_len.set(extracted.as_ref().map(|e| e.len()).unwrap_or(0));
|
self.request_body_len.set(extracted.as_ref().map_or(0, |e| e.len()));
|
||||||
|
|
||||||
// Step 6
|
// Step 6
|
||||||
self.upload_events.set(false);
|
self.upload_events.set(false);
|
||||||
|
@ -1120,13 +1120,12 @@ impl XMLHttpRequest {
|
||||||
let content_type = mime_type.map(|mime|{
|
let content_type = mime_type.map(|mime|{
|
||||||
DOMString::from(format!("{}", mime))
|
DOMString::from(format!("{}", mime))
|
||||||
});
|
});
|
||||||
let document = Document::new(win,
|
Document::new(win,
|
||||||
parsed_url,
|
parsed_url,
|
||||||
is_html_document,
|
is_html_document,
|
||||||
content_type,
|
content_type,
|
||||||
None,
|
None,
|
||||||
DocumentSource::FromParser, docloader);
|
DocumentSource::FromParser, docloader)
|
||||||
document
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn filter_response_headers(&self) -> Headers {
|
fn filter_response_headers(&self) -> Headers {
|
||||||
|
|
|
@ -130,7 +130,7 @@ fn perform_platform_specific_initialization() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
match libc::setrlimit(libc::RLIMIT_NOFILE, &mut rlim) {
|
match libc::setrlimit(libc::RLIMIT_NOFILE, &rlim) {
|
||||||
0 => (),
|
0 => (),
|
||||||
_ => warn!("Failed to set file count limit"),
|
_ => warn!("Failed to set file count limit"),
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,10 +22,9 @@ impl ParseErrorReporter for CSSErrorReporter {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> {
|
fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> {
|
||||||
let error_reporter = box CSSErrorReporter { pipelineid: self.pipelineid, } ;
|
box CSSErrorReporter { pipelineid: self.pipelineid, }
|
||||||
return error_reporter;
|
|
||||||
}
|
}
|
||||||
fn pipeline(&self) -> PipelineId {
|
fn pipeline(&self) -> PipelineId {
|
||||||
return self.pipelineid;
|
self.pipelineid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1948,13 +1948,11 @@ impl ScriptTask {
|
||||||
|
|
||||||
// Notify Constellation about anchors that are no longer mouse over targets.
|
// Notify Constellation about anchors that are no longer mouse over targets.
|
||||||
for target in &*prev_mouse_over_targets {
|
for target in &*prev_mouse_over_targets {
|
||||||
if !mouse_over_targets.contains(target) {
|
if !mouse_over_targets.contains(target) && target.is::<HTMLAnchorElement>() {
|
||||||
if target.is::<HTMLAnchorElement>() {
|
let event = ConstellationMsg::NodeStatus(None);
|
||||||
let event = ConstellationMsg::NodeStatus(None);
|
let ConstellationChan(ref chan) = self.constellation_chan;
|
||||||
let ConstellationChan(ref chan) = self.constellation_chan;
|
chan.send(event).unwrap();
|
||||||
chan.send(event).unwrap();
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2108,7 +2106,7 @@ impl ScriptTask {
|
||||||
let context = Arc::new(Mutex::new(ParserContext::new(id, subpage, script_chan.clone(),
|
let context = Arc::new(Mutex::new(ParserContext::new(id, subpage, script_chan.clone(),
|
||||||
load_data.url.clone())));
|
load_data.url.clone())));
|
||||||
let (action_sender, action_receiver) = ipc::channel().unwrap();
|
let (action_sender, action_receiver) = ipc::channel().unwrap();
|
||||||
let listener = box NetworkListener {
|
let listener = NetworkListener {
|
||||||
context: context,
|
context: context,
|
||||||
script_chan: script_chan.clone(),
|
script_chan: script_chan.clone(),
|
||||||
};
|
};
|
||||||
|
|
|
@ -191,7 +191,7 @@ pub fn handle_get_text(page: &Rc<Page>,
|
||||||
reply: IpcSender<Result<String, ()>>) {
|
reply: IpcSender<Result<String, ()>>) {
|
||||||
reply.send(match find_node_by_unique_id(&*page, pipeline, node_id) {
|
reply.send(match find_node_by_unique_id(&*page, pipeline, node_id) {
|
||||||
Some(ref node) => {
|
Some(ref node) => {
|
||||||
Ok(node.GetTextContent().map(String::from).unwrap_or("".to_owned()))
|
Ok(node.GetTextContent().map_or("".to_owned(), String::from))
|
||||||
},
|
},
|
||||||
None => Err(())
|
None => Err(())
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
|
|
|
@ -112,27 +112,27 @@ impl<'a, E> Element for ElementWrapper<'a, E> where E: Element {
|
||||||
state_pseudo_classes!(snapshot_state_accessors);
|
state_pseudo_classes!(snapshot_state_accessors);
|
||||||
|
|
||||||
fn parent_element(&self) -> Option<Self> {
|
fn parent_element(&self) -> Option<Self> {
|
||||||
self.element.parent_element().map(|el| ElementWrapper::new(el))
|
self.element.parent_element().map(ElementWrapper::new)
|
||||||
}
|
}
|
||||||
fn first_child_element(&self) -> Option<Self> {
|
fn first_child_element(&self) -> Option<Self> {
|
||||||
self.element.first_child_element().map(|el| ElementWrapper::new(el))
|
self.element.first_child_element().map(ElementWrapper::new)
|
||||||
}
|
}
|
||||||
fn last_child_element(&self) -> Option<Self> {
|
fn last_child_element(&self) -> Option<Self> {
|
||||||
self.element.last_child_element().map(|el| ElementWrapper::new(el))
|
self.element.last_child_element().map(ElementWrapper::new)
|
||||||
}
|
}
|
||||||
fn prev_sibling_element(&self) -> Option<Self> {
|
fn prev_sibling_element(&self) -> Option<Self> {
|
||||||
self.element.prev_sibling_element().map(|el| ElementWrapper::new(el))
|
self.element.prev_sibling_element().map(ElementWrapper::new)
|
||||||
}
|
}
|
||||||
fn next_sibling_element(&self) -> Option<Self> {
|
fn next_sibling_element(&self) -> Option<Self> {
|
||||||
self.element.next_sibling_element().map(|el| ElementWrapper::new(el))
|
self.element.next_sibling_element().map(ElementWrapper::new)
|
||||||
}
|
}
|
||||||
fn is_html_element_in_html_document(&self) -> bool {
|
fn is_html_element_in_html_document(&self) -> bool {
|
||||||
self.element.is_html_element_in_html_document()
|
self.element.is_html_element_in_html_document()
|
||||||
}
|
}
|
||||||
fn get_local_name<'b>(&'b self) -> &'b Atom {
|
fn get_local_name(&self) -> &Atom {
|
||||||
self.element.get_local_name()
|
self.element.get_local_name()
|
||||||
}
|
}
|
||||||
fn get_namespace<'b>(&'b self) -> &'b Namespace {
|
fn get_namespace<'b>(&self) -> &Namespace {
|
||||||
self.element.get_namespace()
|
self.element.get_namespace()
|
||||||
}
|
}
|
||||||
fn get_id(&self) -> Option<Atom> {
|
fn get_id(&self) -> Option<Atom> {
|
||||||
|
|
|
@ -47,7 +47,7 @@ impl ParseErrorReporter for StdoutErrorReporter {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pipeline(&self) -> PipelineId {
|
fn pipeline(&self) -> PipelineId {
|
||||||
return PipelineId::fake_root_pipeline_id();
|
PipelineId::fake_root_pipeline_id()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ pub struct Stylist {
|
||||||
impl Stylist {
|
impl Stylist {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(device: Device) -> Stylist {
|
pub fn new(device: Device) -> Stylist {
|
||||||
let stylist = Stylist {
|
Stylist {
|
||||||
viewport_constraints: None,
|
viewport_constraints: None,
|
||||||
device: device,
|
device: device,
|
||||||
is_device_dirty: true,
|
is_device_dirty: true,
|
||||||
|
@ -140,9 +140,8 @@ impl Stylist {
|
||||||
after_map: PerPseudoElementSelectorMap::new(),
|
after_map: PerPseudoElementSelectorMap::new(),
|
||||||
rules_source_order: 0,
|
rules_source_order: 0,
|
||||||
state_deps: DependencySet::new(),
|
state_deps: DependencySet::new(),
|
||||||
};
|
}
|
||||||
// FIXME: Add iso-8859-9.css when the document’s encoding is ISO-8859-8.
|
// FIXME: Add iso-8859-9.css when the document’s encoding is ISO-8859-8.
|
||||||
stylist
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(&mut self, doc_stylesheets: &[Arc<Stylesheet>],
|
pub fn update(&mut self, doc_stylesheets: &[Arc<Stylesheet>],
|
||||||
|
|
|
@ -201,19 +201,16 @@ impl<'a> Iterator for Rules<'a> {
|
||||||
let top = self.stack.len() - 1;
|
let top = self.stack.len() - 1;
|
||||||
while let Some(rule) = self.stack[top].next() {
|
while let Some(rule) = self.stack[top].next() {
|
||||||
// handle conditional group rules
|
// handle conditional group rules
|
||||||
match rule {
|
if let &CSSRule::Media(ref rule) = rule {
|
||||||
&CSSRule::Media(ref rule) => {
|
if let Some(device) = self.device {
|
||||||
if let Some(device) = self.device {
|
if rule.evaluate(device) {
|
||||||
if rule.evaluate(device) {
|
|
||||||
self.stack.push(rule.rules.iter());
|
|
||||||
} else {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
self.stack.push(rule.rules.iter());
|
self.stack.push(rule.rules.iter());
|
||||||
|
} else {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
self.stack.push(rule.rules.iter());
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Some(rule)
|
return Some(rule)
|
||||||
|
|
|
@ -581,11 +581,10 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
|
||||||
let is_running_problem_test =
|
let is_running_problem_test =
|
||||||
url_opt
|
url_opt
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|url|
|
.map_or(false, |url|
|
||||||
url.starts_with("http://web-platform.test:8000/2dcontext/drawing-images-to-the-canvas/") ||
|
url.starts_with("http://web-platform.test:8000/2dcontext/drawing-images-to-the-canvas/") ||
|
||||||
url.starts_with("http://web-platform.test:8000/_mozilla/mozilla/canvas/") ||
|
url.starts_with("http://web-platform.test:8000/_mozilla/mozilla/canvas/") ||
|
||||||
url.starts_with("http://web-platform.test:8000/_mozilla/css/canvas_over_area.html"))
|
url.starts_with("http://web-platform.test:8000/_mozilla/css/canvas_over_area.html"));
|
||||||
.unwrap_or(false);
|
|
||||||
|
|
||||||
let url = match url_opt {
|
let url = match url_opt {
|
||||||
Some(url_string) => {
|
Some(url_string) => {
|
||||||
|
|
|
@ -146,7 +146,7 @@ fn read_prefs() -> Result<HashMap<String, Pref>, ()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_pref(name: &str) -> Arc<PrefValue> {
|
pub fn get_pref(name: &str) -> Arc<PrefValue> {
|
||||||
PREFS.lock().unwrap().get(name).map(|x| x.value().clone()).unwrap_or(Arc::new(PrefValue::Missing))
|
PREFS.lock().unwrap().get(name).map_or(Arc::new(PrefValue::Missing), |x| x.value().clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_pref(name: &str, value: PrefValue) {
|
pub fn set_pref(name: &str, value: PrefValue) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ pub fn resources_dir_path() -> PathBuf {
|
||||||
// FIXME: Find a way to not rely on the executable being
|
// FIXME: Find a way to not rely on the executable being
|
||||||
// under `<servo source>[/$target_triple]/target/debug`
|
// under `<servo source>[/$target_triple]/target/debug`
|
||||||
// or `<servo source>[/$target_triple]/target/release`.
|
// or `<servo source>[/$target_triple]/target/release`.
|
||||||
let mut path = env::current_exe().ok().expect("can't get exe path");
|
let mut path = env::current_exe().expect("can't get exe path");
|
||||||
path.pop();
|
path.pop();
|
||||||
path.push("resources");
|
path.push("resources");
|
||||||
if !path.is_dir() { // resources dir not in same dir as exe?
|
if !path.is_dir() { // resources dir not in same dir as exe?
|
||||||
|
|
|
@ -461,19 +461,17 @@ pub fn parse_legacy_color(mut input: &str) -> Result<RGBA, ()> {
|
||||||
|
|
||||||
// Step 6.
|
// Step 6.
|
||||||
if input.len() == 4 {
|
if input.len() == 4 {
|
||||||
match (input.as_bytes()[0],
|
if let (b'#', Ok(r), Ok(g), Ok(b)) =
|
||||||
hex(input.as_bytes()[1] as char),
|
(input.as_bytes()[0],
|
||||||
hex(input.as_bytes()[2] as char),
|
hex(input.as_bytes()[1] as char),
|
||||||
hex(input.as_bytes()[3] as char)) {
|
hex(input.as_bytes()[2] as char),
|
||||||
(b'#', Ok(r), Ok(g), Ok(b)) => {
|
hex(input.as_bytes()[3] as char)) {
|
||||||
return Ok(RGBA {
|
return Ok(RGBA {
|
||||||
red: (r as f32) * 17.0 / 255.0,
|
red: (r as f32) * 17.0 / 255.0,
|
||||||
green: (g as f32) * 17.0 / 255.0,
|
green: (g as f32) * 17.0 / 255.0,
|
||||||
blue: (b as f32) * 17.0 / 255.0,
|
blue: (b as f32) * 17.0 / 255.0,
|
||||||
alpha: 1.0,
|
alpha: 1.0,
|
||||||
})
|
})
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue