Skip to content

Commit

Permalink
Rustfmt and make tidy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
ferjm committed Oct 8, 2018
1 parent f4ba7e5 commit 50582f1
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 40 deletions.
2 changes: 1 addition & 1 deletion components/layout/fragment.rs
Expand Up @@ -31,8 +31,8 @@ use msg::constellation_msg::{BrowsingContextId, PipelineId};
use net_traits::image::base::{Image, ImageMetadata};
use net_traits::image_cache::{ImageOrMetadataAvailable, UsePlaceholder};
use range::*;
use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
use script_layout_interface::{HTMLCanvasData, HTMLCanvasDataSource, HTMLMediaData, SVGSVGData};
use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
use serde::ser::{Serialize, SerializeStruct, Serializer};
use servo_url::ServoUrl;
use std::{f32, fmt};
Expand Down
70 changes: 37 additions & 33 deletions components/script/dom/htmlmediaelement.rs
Expand Up @@ -43,9 +43,9 @@ use net_traits::request::{CredentialsMode, Destination, RequestInit};
use network_listener::{NetworkListener, PreInvoke};
use script_layout_interface::HTMLMediaData;
use script_thread::ScriptThread;
use servo_media::ServoMedia;
use servo_media::player::{PlaybackState, Player, PlayerEvent};
use servo_media::player::frame::{Frame, FrameRenderer};
use servo_media::ServoMedia;
use servo_url::ServoUrl;
use std::cell::Cell;
use std::collections::VecDeque;
Expand Down Expand Up @@ -112,12 +112,12 @@ impl FrameRenderer for MediaFrameRenderer {
*image_key = new_image_key;
*width = frame.get_width();
*height = frame.get_height();
}
},
None => {
let image_key = self.api.generate_image_key();
txn.add_image(image_key, descriptor, image_data, None);
self.current_frame = Some((image_key, frame.get_width(), frame.get_height()));
}
},
}

self.api.update_resources(txn.resource_updates);
Expand Down Expand Up @@ -164,9 +164,9 @@ pub struct HTMLMediaElement {
#[ignore_malloc_size_of = "Arc"]
frame_renderer: Arc<Mutex<MediaFrameRenderer>>,
fetch_canceller: DomRefCell<FetchCanceller>,
/// https://html.spec.whatwg.org/multipage/media.html#show-poster-flag
/// https://html.spec.whatwg.org/multipage/#show-poster-flag
show_poster: Cell<bool>,
/// https://html.spec.whatwg.org/multipage/media.html#dom-media-duration
/// https://html.spec.whatwg.org/multipage/#dom-media-duration
duration: Cell<f64>,
}

Expand Down Expand Up @@ -210,8 +210,9 @@ impl HTMLMediaElement {
in_flight_play_promises_queue: Default::default(),
have_metadata: Cell::new(false),
player: ServoMedia::get().unwrap().create_player().unwrap(),
frame_renderer:
Arc::new(Mutex::new(MediaFrameRenderer::new(document.window().get_webrender_api_sender()))),
frame_renderer: Arc::new(Mutex::new(MediaFrameRenderer::new(
document.window().get_webrender_api_sender(),
))),
fetch_canceller: DomRefCell::new(Default::default()),
show_poster: Cell::new(true),
duration: Cell::new(f64::NAN),
Expand Down Expand Up @@ -321,7 +322,8 @@ impl HTMLMediaElement {
});
}),
window.upcast(),
).unwrap();
)
.unwrap();
}

// Step 8.
Expand All @@ -331,7 +333,7 @@ impl HTMLMediaElement {
// Not applicable here, the promise is returned from Play.
}

/// https://html.spec.whatwg.org/multipage/media.html#time-marches-on
/// https://html.spec.whatwg.org/multipage/#time-marches-on
fn time_marches_on(&self) {
// TODO: implement this.
}
Expand Down Expand Up @@ -540,7 +542,7 @@ impl HTMLMediaElement {
fn resource_selection_algorithm_sync(&self, base_url: ServoUrl) {
// Step 5.
// FIXME(ferjm): Implement blocked_on_parser logic
// https://html.spec.whatwg.org/multipage/media.html#blocked-on-parser
// https://html.spec.whatwg.org/multipage/#blocked-on-parser
// FIXME(nox): Maybe populate the list of pending text tracks.

// Step 6.
Expand Down Expand Up @@ -670,7 +672,8 @@ impl HTMLMediaElement {
this.root().delay_load_event(false);
}),
window.upcast(),
).unwrap();
)
.unwrap();

// Steps 4.remote.1.4.
// FIXME(nox): Somehow we should wait for the task from previous
Expand Down Expand Up @@ -719,8 +722,13 @@ impl HTMLMediaElement {
);
let cancel_receiver = self.fetch_canceller.borrow_mut().initialize();
let global = self.global();
global.core_resource_thread().send(
CoreResourceMsg::Fetch(request, FetchChannels::ResponseMsg(action_sender, Some(cancel_receiver)))).unwrap();
global
.core_resource_thread()
.send(CoreResourceMsg::Fetch(
request,
FetchChannels::ResponseMsg(action_sender, Some(cancel_receiver)),
))
.unwrap();
},
Resource::Object => {
// FIXME(nox): Actually do something with the object.
Expand Down Expand Up @@ -931,7 +939,8 @@ impl HTMLMediaElement {
let (action_sender, action_receiver) = ipc::channel().unwrap();

self.player.register_event_handler(action_sender);
self.player.register_frame_renderer(self.frame_renderer.clone());
self.player
.register_frame_renderer(self.frame_renderer.clone());
// XXXferjm this can fail.
self.player.setup().unwrap();

Expand All @@ -950,7 +959,8 @@ impl HTMLMediaElement {
this.root().handle_player_event(&event);
}),
&task_canceller,
).unwrap();
)
.unwrap();
}),
);
}
Expand Down Expand Up @@ -979,52 +989,46 @@ impl HTMLMediaElement {
}
let window = window_from_node(self);
let task_source = window.dom_manipulation_task_source();
task_source.queue_simple_event(
self.upcast(),
atom!("durationchange"),
&window,
);
task_source.queue_simple_event(self.upcast(), atom!("durationchange"), &window);

// Step 5.
if self.is::<HTMLVideoElement>() {
assert_ne!(self.ready_state.get(), ReadyState::HaveNothing);
let video_elem = self.downcast::<HTMLVideoElement>().unwrap();
video_elem.set_video_width(metadata.width);
video_elem.set_video_height(metadata.height);
task_source.queue_simple_event(
self.upcast(),
atom!("resize"),
&window,
);
task_source.queue_simple_event(self.upcast(), atom!("resize"), &window);
}

// Step 6.
self.change_ready_state(ReadyState::HaveMetadata);
self.have_metadata.set(true);

// XXX(ferjm) Steps 7 to 13.
} else {
// => set the element's delaying-the-load-event flag to false
self.change_ready_state(ReadyState::HaveCurrentData);
}
}
},
PlayerEvent::StateChanged(ref state) => match *state {
PlaybackState::Paused => {
if self.ready_state.get() == ReadyState::HaveMetadata {
self.change_ready_state(ReadyState::HaveEnoughData);
}
}
_ => {}
},
_ => {},
},
PlayerEvent::EndOfStream => {}
PlayerEvent::EndOfStream => {},
PlayerEvent::FrameUpdated => {
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
}
},
PlayerEvent::Error => {
self.error.set(Some(&*MediaError::new(
&*window_from_node(self),
MEDIA_ERR_DECODE,
)));
self.upcast::<EventTarget>().fire_event(atom!("error"));
}
},
}
}
}
Expand Down Expand Up @@ -1117,7 +1121,7 @@ impl HTMLMediaElementMethods for HTMLMediaElement {
self.paused.get()
}

// https://html.spec.whatwg.org/multipage/media.html#dom-media-duration
// https://html.spec.whatwg.org/multipage/#dom-media-duration
fn Duration(&self) -> f64 {
self.duration.get()
}
Expand Down Expand Up @@ -1301,7 +1305,7 @@ impl FetchResponseListener for HTMLMediaElementContext {
// Until then, we comment out the failure steps.
//
//elem.queue_dedicated_media_source_failure_steps();
// => "Once the entire media resource has been fetched..."
// => "Once the entire media resource has been fetched..."
} else if status.is_ok() {
elem.change_ready_state(ReadyState::HaveEnoughData);

Expand Down
6 changes: 4 additions & 2 deletions components/script/dom/htmlvideoelement.rs
Expand Up @@ -15,9 +15,9 @@ use std::cell::Cell;
#[dom_struct]
pub struct HTMLVideoElement {
htmlmediaelement: HTMLMediaElement,
/// https://html.spec.whatwg.org/multipage/media.html#dom-video-videowidth
/// https://html.spec.whatwg.org/multipage/#dom-video-videowidth
video_width: Cell<u32>,
/// https://html.spec.whatwg.org/multipage/media.html#dom-video-videoheight
/// https://html.spec.whatwg.org/multipage/#dom-video-videoheight
video_height: Cell<u32>,
}

Expand Down Expand Up @@ -59,13 +59,15 @@ impl HTMLVideoElement {
}

impl HTMLVideoElementMethods for HTMLVideoElement {
// https://html.spec.whatwg.org/multipage/#dom-video-videowidth
fn VideoWidth(&self) -> u32 {
if self.htmlmediaelement.get_ready_state() == ReadyState::HaveNothing {
return 0;
}
self.video_width.get()
}

// https://html.spec.whatwg.org/multipage/#dom-video-videoheight
fn VideoHeight(&self) -> u32 {
if self.htmlmediaelement.get_ready_state() == ReadyState::HaveNothing {
return 0;
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/node.rs
Expand Up @@ -63,9 +63,9 @@ use libc::{self, c_void, uintptr_t};
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
use msg::constellation_msg::{BrowsingContextId, PipelineId};
use ref_slice::ref_slice;
use script_layout_interface::message::Msg;
use script_layout_interface::{HTMLCanvasData, HTMLMediaData, LayoutElementType, LayoutNodeType};
use script_layout_interface::{OpaqueStyleAndLayoutData, SVGSVGData, TrustedNodeAddress};
use script_layout_interface::message::Msg;
use script_thread::ScriptThread;
use script_traits::DocumentActivity;
use script_traits::UntrustedNodeAddress;
Expand Down
4 changes: 1 addition & 3 deletions components/script_traits/lib.rs
Expand Up @@ -72,9 +72,7 @@ use style_traits::CSSPixel;
use style_traits::SpeculativePainter;
use style_traits::cursor::CursorKind;
use webdriver_msg::{LoadStatus, WebDriverScriptCommand};
use webrender_api::{
DevicePixel, DeviceUintSize, DocumentId, ExternalScrollId, ImageKey, RenderApiSender,
};
use webrender_api::{DevicePixel, DeviceUintSize, DocumentId, ExternalScrollId, ImageKey, RenderApiSender};
use webvr_traits::{WebVREvent, WebVRMsg};

pub use script_msg::{LayoutMsg, ScriptMsg, EventResult, LogEntry};
Expand Down

0 comments on commit 50582f1

Please sign in to comment.