Auto merge of #21693 - chansuke:format_script_traits, r=jdm

Format components/script_traits

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix part of #21373.
- [x] These changes do not require tests because format the code only.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21693)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-09-12 21:57:30 -04:00 committed by GitHub
commit d348777fc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 96 additions and 35 deletions

View file

@ -28,7 +28,8 @@ extern crate msg;
extern crate net_traits; extern crate net_traits;
extern crate profile_traits; extern crate profile_traits;
extern crate rustc_serialize; extern crate rustc_serialize;
#[macro_use] extern crate serde; #[macro_use]
extern crate serde;
extern crate servo_atoms; extern crate servo_atoms;
extern crate servo_channel; extern crate servo_channel;
extern crate servo_url; extern crate servo_url;
@ -135,12 +136,16 @@ pub struct LoadData {
/// The creator pipeline id if this is an about:blank load. /// The creator pipeline id if this is an about:blank load.
pub creator_pipeline_id: Option<PipelineId>, pub creator_pipeline_id: Option<PipelineId>,
/// The method. /// The method.
#[serde(deserialize_with = "::hyper_serde::deserialize", #[serde(
serialize_with = "::hyper_serde::serialize")] deserialize_with = "::hyper_serde::deserialize",
serialize_with = "::hyper_serde::serialize"
)]
pub method: Method, pub method: Method,
/// The headers. /// The headers.
#[serde(deserialize_with = "::hyper_serde::deserialize", #[serde(
serialize_with = "::hyper_serde::serialize")] deserialize_with = "::hyper_serde::deserialize",
serialize_with = "::hyper_serde::serialize"
)]
pub headers: Headers, pub headers: Headers,
/// The data. /// The data.
pub data: Option<Vec<u8>>, pub data: Option<Vec<u8>>,
@ -159,16 +164,17 @@ pub enum JsEvalResult {
/// <https://html.spec.whatwg.org/multipage/#navigate> 12.11 /// <https://html.spec.whatwg.org/multipage/#navigate> 12.11
NoContent, NoContent,
/// The js evaluation had a string result. /// The js evaluation had a string result.
Ok(Vec<u8>) Ok(Vec<u8>),
} }
impl LoadData { impl LoadData {
/// Create a new `LoadData` object. /// Create a new `LoadData` object.
pub fn new(url: ServoUrl, pub fn new(
url: ServoUrl,
creator_pipeline_id: Option<PipelineId>, creator_pipeline_id: Option<PipelineId>,
referrer_policy: Option<ReferrerPolicy>, referrer_policy: Option<ReferrerPolicy>,
referrer_url: Option<ServoUrl>) referrer_url: Option<ServoUrl>,
-> LoadData { ) -> LoadData {
LoadData { LoadData {
url: url, url: url,
creator_pipeline_id: creator_pipeline_id, creator_pipeline_id: creator_pipeline_id,
@ -294,7 +300,12 @@ pub enum ConstellationControlMsg {
PostMessage(PipelineId, Option<ImmutableOrigin>, Vec<u8>), PostMessage(PipelineId, Option<ImmutableOrigin>, Vec<u8>),
/// Updates the current pipeline ID of a given iframe. /// Updates the current pipeline ID of a given iframe.
/// First PipelineId is for the parent, second is the new PipelineId for the frame. /// First PipelineId is for the parent, second is the new PipelineId for the frame.
UpdatePipelineId(PipelineId, BrowsingContextId, PipelineId, UpdatePipelineIdReason), UpdatePipelineId(
PipelineId,
BrowsingContextId,
PipelineId,
UpdatePipelineIdReason,
),
/// Updates the history state and url of a given pipeline. /// Updates the history state and url of a given pipeline.
UpdateHistoryState(PipelineId, Option<HistoryStateId>, ServoUrl), UpdateHistoryState(PipelineId, Option<HistoryStateId>, ServoUrl),
/// Removes inaccesible history states. /// Removes inaccesible history states.
@ -322,7 +333,14 @@ pub enum ConstellationControlMsg {
}, },
/// Cause a `storage` event to be dispatched at the appropriate window. /// Cause a `storage` event to be dispatched at the appropriate window.
/// The strings are key, old value and new value. /// The strings are key, old value and new value.
DispatchStorageEvent(PipelineId, StorageType, ServoUrl, Option<String>, Option<String>, Option<String>), DispatchStorageEvent(
PipelineId,
StorageType,
ServoUrl,
Option<String>,
Option<String>,
Option<String>,
),
/// Report an error from a CSS parser for the given pipeline /// Report an error from a CSS parser for the given pipeline
ReportCSSError(PipelineId, String, u32, u32, String), ReportCSSError(PipelineId, String, u32, u32, String),
/// Reload the given page. /// Reload the given page.
@ -447,19 +465,29 @@ pub enum CompositorEvent {
MouseButton, MouseButton,
Point2D<f32>, Point2D<f32>,
Option<UntrustedNodeAddress>, Option<UntrustedNodeAddress>,
Option<Point2D<f32>> Option<Point2D<f32>>,
), ),
/// The mouse was moved over a point (or was moved out of the recognizable region). /// The mouse was moved over a point (or was moved out of the recognizable region).
MouseMoveEvent(Option<Point2D<f32>>, Option<UntrustedNodeAddress>), MouseMoveEvent(Option<Point2D<f32>>, Option<UntrustedNodeAddress>),
/// A touch event was generated with a touch ID and location. /// A touch event was generated with a touch ID and location.
TouchEvent(TouchEventType, TouchId, Point2D<f32>, Option<UntrustedNodeAddress>), TouchEvent(
TouchEventType,
TouchId,
Point2D<f32>,
Option<UntrustedNodeAddress>,
),
/// A key was pressed. /// A key was pressed.
KeyEvent(Option<char>, Key, KeyState, KeyModifiers), KeyEvent(Option<char>, Key, KeyState, KeyModifiers),
} }
/// Requests a TimerEvent-Message be sent after the given duration. /// Requests a TimerEvent-Message be sent after the given duration.
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize)]
pub struct TimerEventRequest(pub IpcSender<TimerEvent>, pub TimerSource, pub TimerEventId, pub MsDuration); pub struct TimerEventRequest(
pub IpcSender<TimerEvent>,
pub TimerSource,
pub TimerEventId,
pub MsDuration,
);
/// Type of messages that can be sent to the timer scheduler. /// Type of messages that can be sent to the timer scheduler.
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize)]
@ -568,8 +596,10 @@ pub trait ScriptThreadFactory {
/// Type of message sent from script to layout. /// Type of message sent from script to layout.
type Message; type Message;
/// Create a `ScriptThread`. /// Create a `ScriptThread`.
fn create(state: InitialScriptState, load_data: LoadData) fn create(
-> (Sender<Self::Message>, Receiver<Self::Message>); state: InitialScriptState,
load_data: LoadData,
) -> (Sender<Self::Message>, Receiver<Self::Message>);
} }
/// Whether the sandbox attribute is present for an iframe element /// Whether the sandbox attribute is present for an iframe element
@ -678,7 +708,11 @@ pub enum WebDriverCommandMsg {
/// Act as if keys were pressed in the browsing context with the given ID. /// Act as if keys were pressed in the browsing context with the given ID.
SendKeys(BrowsingContextId, Vec<(Key, KeyModifiers, KeyState)>), SendKeys(BrowsingContextId, Vec<(Key, KeyModifiers, KeyState)>),
/// Set the window size. /// Set the window size.
SetWindowSize(TopLevelBrowsingContextId, DeviceUintSize, IpcSender<WindowSizeData>), SetWindowSize(
TopLevelBrowsingContextId,
DeviceUintSize,
IpcSender<WindowSizeData>,
),
/// Take a screenshot of the window. /// Take a screenshot of the window.
TakeScreenshot(TopLevelBrowsingContextId, IpcSender<Option<Image>>), TakeScreenshot(TopLevelBrowsingContextId, IpcSender<Option<Image>>),
} }
@ -706,7 +740,11 @@ pub enum ConstellationMsg {
/// Request to traverse the joint session history of the provided browsing context. /// Request to traverse the joint session history of the provided browsing context.
TraverseHistory(TopLevelBrowsingContextId, TraversalDirection), TraverseHistory(TopLevelBrowsingContextId, TraversalDirection),
/// Inform the constellation of a window being resized. /// Inform the constellation of a window being resized.
WindowSize(Option<TopLevelBrowsingContextId>, WindowSizeData, WindowSizeType), WindowSize(
Option<TopLevelBrowsingContextId>,
WindowSizeData,
WindowSizeType,
),
/// Requests that the constellation instruct layout to begin a new tick of the animation. /// Requests that the constellation instruct layout to begin a new tick of the animation.
TickAnimation(PipelineId, AnimationTickType), TickAnimation(PipelineId, AnimationTickType),
/// Dispatch a webdriver command /// Dispatch a webdriver command
@ -808,17 +846,20 @@ pub enum PaintWorkletError {
/// Execute paint code in the worklet thread pool. /// Execute paint code in the worklet thread pool.
pub trait Painter: SpeculativePainter { pub trait Painter: SpeculativePainter {
/// <https://drafts.css-houdini.org/css-paint-api/#draw-a-paint-image> /// <https://drafts.css-houdini.org/css-paint-api/#draw-a-paint-image>
fn draw_a_paint_image(&self, fn draw_a_paint_image(
&self,
size: TypedSize2D<f32, CSSPixel>, size: TypedSize2D<f32, CSSPixel>,
zoom: TypedScale<f32, CSSPixel, DevicePixel>, zoom: TypedScale<f32, CSSPixel, DevicePixel>,
properties: Vec<(Atom, String)>, properties: Vec<(Atom, String)>,
arguments: Vec<String>) arguments: Vec<String>,
-> Result<DrawAPaintImageResult, PaintWorkletError>; ) -> Result<DrawAPaintImageResult, PaintWorkletError>;
} }
impl fmt::Debug for Painter { impl fmt::Debug for Painter {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.debug_tuple("Painter").field(&format_args!("..")).finish() fmt.debug_tuple("Painter")
.field(&format_args!(".."))
.finish()
} }
} }

View file

@ -92,7 +92,13 @@ pub enum ScriptMsg {
InitiateNavigateRequest(RequestInit, /* cancellation_chan */ IpcReceiver<()>), InitiateNavigateRequest(RequestInit, /* cancellation_chan */ IpcReceiver<()>),
/// Broadcast a storage event to every same-origin pipeline. /// Broadcast a storage event to every same-origin pipeline.
/// The strings are key, old value and new value. /// The strings are key, old value and new value.
BroadcastStorageEvent(StorageType, ServoUrl, Option<String>, Option<String>, Option<String>), BroadcastStorageEvent(
StorageType,
ServoUrl,
Option<String>,
Option<String>,
Option<String>,
),
/// Indicates whether this pipeline is currently running animations. /// Indicates whether this pipeline is currently running animations.
ChangeRunningAnimationsState(AnimationState), ChangeRunningAnimationsState(AnimationState),
/// Requests that a new 2D canvas thread be created. (This is done in the constellation because /// Requests that a new 2D canvas thread be created. (This is done in the constellation because
@ -107,9 +113,16 @@ pub enum ScriptMsg {
/// Get the parent info for a given pipeline. /// Get the parent info for a given pipeline.
GetParentInfo(PipelineId, IpcSender<Option<PipelineId>>), GetParentInfo(PipelineId, IpcSender<Option<PipelineId>>),
/// Get the top-level browsing context info for a given browsing context. /// Get the top-level browsing context info for a given browsing context.
GetTopForBrowsingContext(BrowsingContextId, IpcSender<Option<TopLevelBrowsingContextId>>), GetTopForBrowsingContext(
BrowsingContextId,
IpcSender<Option<TopLevelBrowsingContextId>>,
),
/// Get the nth child browsing context ID for a given browsing context, sorted in tree order. /// Get the nth child browsing context ID for a given browsing context, sorted in tree order.
GetChildBrowsingContextId(BrowsingContextId, usize, IpcSender<Option<BrowsingContextId>>), GetChildBrowsingContextId(
BrowsingContextId,
usize,
IpcSender<Option<BrowsingContextId>>,
),
/// All pending loads are complete, and the `load` event for this pipeline /// All pending loads are complete, and the `load` event for this pipeline
/// has been dispatched. /// has been dispatched.
LoadComplete, LoadComplete,
@ -142,7 +155,10 @@ pub enum ScriptMsg {
/// A load of the initial `about:blank` has been completed in an IFrame. /// A load of the initial `about:blank` has been completed in an IFrame.
ScriptNewIFrame(IFrameLoadInfo, IpcSender<LayoutControlMsg>), ScriptNewIFrame(IFrameLoadInfo, IpcSender<LayoutControlMsg>),
/// Script has opened a new auxiliary browsing context. /// Script has opened a new auxiliary browsing context.
ScriptNewAuxiliary(AuxiliaryBrowsingContextLoadInfo, IpcSender<LayoutControlMsg>), ScriptNewAuxiliary(
AuxiliaryBrowsingContextLoadInfo,
IpcSender<LayoutControlMsg>,
),
/// Requests that the constellation set the contents of the clipboard /// Requests that the constellation set the contents of the clipboard
SetClipboardContents(String), SetClipboardContents(String),
/// Mark a new document as active /// Mark a new document as active

View file

@ -14,10 +14,14 @@ use servo_url::ServoUrl;
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize)]
pub enum WebDriverScriptCommand { pub enum WebDriverScriptCommand {
AddCookie(#[serde(deserialize_with = "::hyper_serde::deserialize", AddCookie(
serialize_with = "::hyper_serde::serialize")] #[serde(
deserialize_with = "::hyper_serde::deserialize",
serialize_with = "::hyper_serde::serialize"
)]
Cookie<'static>, Cookie<'static>,
IpcSender<Result<(), WebDriverCookieError>>), IpcSender<Result<(), WebDriverCookieError>>,
),
ExecuteScript(String, IpcSender<WebDriverJSResult>), ExecuteScript(String, IpcSender<WebDriverJSResult>),
ExecuteAsyncScript(String, IpcSender<WebDriverJSResult>), ExecuteAsyncScript(String, IpcSender<WebDriverJSResult>),
FindElementCSS(String, IpcSender<Result<Option<String>, ()>>), FindElementCSS(String, IpcSender<Result<Option<String>, ()>>),