mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #10222 - faineance:master, r=KiChjang
Use self.0 instead of destructuring single item tuple structs. Closes #9698. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10222) <!-- Reviewable:end -->
This commit is contained in:
commit
b97ffffb48
17 changed files with 37 additions and 71 deletions
|
@ -29,8 +29,7 @@ struct SurfaceKey([i32; 2]);
|
||||||
|
|
||||||
impl Hash for SurfaceKey {
|
impl Hash for SurfaceKey {
|
||||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||||
let SurfaceKey(ref bytes) = *self;
|
self.0.hash(state);
|
||||||
bytes.hash(state);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,8 +140,7 @@ pub struct Epoch(pub u32);
|
||||||
|
|
||||||
impl Epoch {
|
impl Epoch {
|
||||||
pub fn next(&mut self) {
|
pub fn next(&mut self) {
|
||||||
let Epoch(ref mut u) = *self;
|
self.0 += 1;
|
||||||
*u += 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +149,6 @@ pub struct FrameTreeId(pub u32);
|
||||||
|
|
||||||
impl FrameTreeId {
|
impl FrameTreeId {
|
||||||
pub fn next(&mut self) {
|
pub fn next(&mut self) {
|
||||||
let FrameTreeId(ref mut u) = *self;
|
self.0 += 1;
|
||||||
*u += 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -471,8 +471,7 @@ impl<'a> PreorderFlowTraversal for AbsoluteAssignBSizesTraversal<'a> {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let AbsoluteAssignBSizesTraversal(ref layout_context) = *self;
|
block.calculate_absolute_block_size_and_margins(&self.0);
|
||||||
block.calculate_absolute_block_size_and_margins(*layout_context);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,6 @@ impl OpaqueNodeMethods for OpaqueNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_untrusted_node_address(&self) -> UntrustedNodeAddress {
|
fn to_untrusted_node_address(&self) -> UntrustedNodeAddress {
|
||||||
let OpaqueNode(addr) = *self;
|
UntrustedNodeAddress(self.0 as *const c_void)
|
||||||
UntrustedNodeAddress(addr as *const c_void)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,16 +124,14 @@ impl BasicCORSCache {
|
||||||
fn find_entry_by_header<'a>(&'a mut self, request: &CacheRequestDetails,
|
fn find_entry_by_header<'a>(&'a mut self, request: &CacheRequestDetails,
|
||||||
header_name: &str) -> Option<&'a mut CORSCacheEntry> {
|
header_name: &str) -> Option<&'a mut CORSCacheEntry> {
|
||||||
self.cleanup();
|
self.cleanup();
|
||||||
let BasicCORSCache(ref mut buf) = *self;
|
self.0.iter_mut().find(|e| match_headers(e, request) && e.header_or_method.match_header(header_name))
|
||||||
buf.iter_mut().find(|e| match_headers(e, request) && e.header_or_method.match_header(header_name))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_entry_by_method<'a>(&'a mut self, request: &CacheRequestDetails,
|
fn find_entry_by_method<'a>(&'a mut self, request: &CacheRequestDetails,
|
||||||
method: Method) -> Option<&'a mut CORSCacheEntry> {
|
method: Method) -> Option<&'a mut CORSCacheEntry> {
|
||||||
// we can take the method from CORSRequest itself
|
// we can take the method from CORSRequest itself
|
||||||
self.cleanup();
|
self.cleanup();
|
||||||
let BasicCORSCache(ref mut buf) = *self;
|
self.0.iter_mut().find(|e| match_headers(e, request) && e.header_or_method.match_method(&method))
|
||||||
buf.iter_mut().find(|e| match_headers(e, request) && e.header_or_method.match_method(&method))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,8 +188,7 @@ impl CORSCache for BasicCORSCache {
|
||||||
|
|
||||||
fn insert(&mut self, entry: CORSCacheEntry) {
|
fn insert(&mut self, entry: CORSCacheEntry) {
|
||||||
self.cleanup();
|
self.cleanup();
|
||||||
let BasicCORSCache(ref mut buf) = *self;
|
self.0.push(entry);
|
||||||
buf.push(entry);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,7 @@ impl ProfilerChan {
|
||||||
///
|
///
|
||||||
/// Panics if the send fails.
|
/// Panics if the send fails.
|
||||||
pub fn send(&self, msg: ProfilerMsg) {
|
pub fn send(&self, msg: ProfilerMsg) {
|
||||||
let ProfilerChan(ref c) = *self;
|
self.0.send(msg).unwrap();
|
||||||
c.send(msg).unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Runs `f()` with memory profiling.
|
/// Runs `f()` with memory profiling.
|
||||||
|
@ -118,8 +117,7 @@ impl ReportsChan {
|
||||||
///
|
///
|
||||||
/// Panics if the send fails.
|
/// Panics if the send fails.
|
||||||
pub fn send(&self, report: Vec<Report>) {
|
pub fn send(&self, report: Vec<Report>) {
|
||||||
let ReportsChan(ref c) = *self;
|
self.0.send(report).unwrap();
|
||||||
c.send(report).unwrap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,7 @@ pub struct ProfilerChan(pub IpcSender<ProfilerMsg>);
|
||||||
|
|
||||||
impl ProfilerChan {
|
impl ProfilerChan {
|
||||||
pub fn send(&self, msg: ProfilerMsg) {
|
pub fn send(&self, msg: ProfilerMsg) {
|
||||||
let ProfilerChan(ref c) = *self;
|
self.0.send(msg).unwrap();
|
||||||
c.send(msg).unwrap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -394,9 +394,8 @@ impl CORSCache {
|
||||||
header_name: &str)
|
header_name: &str)
|
||||||
-> Option<&'a mut CORSCacheEntry> {
|
-> Option<&'a mut CORSCacheEntry> {
|
||||||
self.cleanup();
|
self.cleanup();
|
||||||
let CORSCache(ref mut buf) = *self;
|
|
||||||
// Credentials are not yet implemented here
|
// Credentials are not yet implemented here
|
||||||
buf.iter_mut().find(|e| {
|
self.0.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)
|
||||||
|
@ -421,9 +420,8 @@ impl CORSCache {
|
||||||
-> Option<&'a mut CORSCacheEntry> {
|
-> Option<&'a mut CORSCacheEntry> {
|
||||||
// we can take the method from CORSRequest itself
|
// we can take the method from CORSRequest itself
|
||||||
self.cleanup();
|
self.cleanup();
|
||||||
let CORSCache(ref mut buf) = *self;
|
|
||||||
// Credentials are not yet implemented here
|
// Credentials are not yet implemented here
|
||||||
buf.iter_mut().find(|e| {
|
self.0.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)
|
||||||
|
@ -445,8 +443,7 @@ impl CORSCache {
|
||||||
|
|
||||||
fn insert(&mut self, entry: CORSCacheEntry) {
|
fn insert(&mut self, entry: CORSCacheEntry) {
|
||||||
self.cleanup();
|
self.cleanup();
|
||||||
let CORSCache(ref mut buf) = *self;
|
self.0.push(entry);
|
||||||
buf.push(entry);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,8 +58,7 @@ impl Into<Vec<u8>> for ByteString {
|
||||||
|
|
||||||
impl Hash for ByteString {
|
impl Hash for ByteString {
|
||||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||||
let ByteString(ref vec) = *self;
|
self.0.hash(state);
|
||||||
vec.hash(state);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -321,13 +321,11 @@ pub struct SendableMainThreadScriptChan(pub Sender<CommonScriptMsg>);
|
||||||
|
|
||||||
impl ScriptChan for SendableMainThreadScriptChan {
|
impl ScriptChan for SendableMainThreadScriptChan {
|
||||||
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
|
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
|
||||||
let SendableMainThreadScriptChan(ref chan) = *self;
|
self.0.send(msg).map_err(|_| ())
|
||||||
chan.send(msg).map_err(|_| ())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone(&self) -> Box<ScriptChan + Send> {
|
fn clone(&self) -> Box<ScriptChan + Send> {
|
||||||
let SendableMainThreadScriptChan(ref chan) = *self;
|
box SendableMainThreadScriptChan((&self.0).clone())
|
||||||
box SendableMainThreadScriptChan((*chan).clone())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,13 +343,11 @@ pub struct MainThreadScriptChan(pub Sender<MainThreadScriptMsg>);
|
||||||
|
|
||||||
impl ScriptChan for MainThreadScriptChan {
|
impl ScriptChan for MainThreadScriptChan {
|
||||||
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
|
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
|
||||||
let MainThreadScriptChan(ref chan) = *self;
|
self.0.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
|
||||||
chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone(&self) -> Box<ScriptChan + Send> {
|
fn clone(&self) -> Box<ScriptChan + Send> {
|
||||||
let MainThreadScriptChan(ref chan) = *self;
|
box MainThreadScriptChan((&self.0).clone())
|
||||||
box MainThreadScriptChan((*chan).clone())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,13 +16,11 @@ pub struct DOMManipulationTaskSource(pub Sender<MainThreadScriptMsg>);
|
||||||
|
|
||||||
impl TaskSource<DOMManipulationTask> for DOMManipulationTaskSource {
|
impl TaskSource<DOMManipulationTask> for DOMManipulationTaskSource {
|
||||||
fn queue(&self, msg: DOMManipulationTask) -> Result<(), ()> {
|
fn queue(&self, msg: DOMManipulationTask) -> Result<(), ()> {
|
||||||
let DOMManipulationTaskSource(ref chan) = *self;
|
self.0.send(MainThreadScriptMsg::DOMManipulation(msg)).map_err(|_| ())
|
||||||
chan.send(MainThreadScriptMsg::DOMManipulation(msg)).map_err(|_| ())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone(&self) -> Box<TaskSource<DOMManipulationTask> + Send> {
|
fn clone(&self) -> Box<TaskSource<DOMManipulationTask> + Send> {
|
||||||
let DOMManipulationTaskSource(ref chan) = *self;
|
box DOMManipulationTaskSource((&self.0).clone())
|
||||||
box DOMManipulationTaskSource((*chan).clone())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,10 @@ pub struct FileReadingTaskSource(pub Sender<MainThreadScriptMsg>);
|
||||||
|
|
||||||
impl ScriptChan for FileReadingTaskSource {
|
impl ScriptChan for FileReadingTaskSource {
|
||||||
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
|
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
|
||||||
let FileReadingTaskSource(ref chan) = *self;
|
self.0.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
|
||||||
chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone(&self) -> Box<ScriptChan + Send> {
|
fn clone(&self) -> Box<ScriptChan + Send> {
|
||||||
let FileReadingTaskSource(ref chan) = *self;
|
box FileReadingTaskSource((&self.0).clone())
|
||||||
box FileReadingTaskSource((*chan).clone())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,10 @@ pub struct HistoryTraversalTaskSource(pub Sender<MainThreadScriptMsg>);
|
||||||
|
|
||||||
impl ScriptChan for HistoryTraversalTaskSource {
|
impl ScriptChan for HistoryTraversalTaskSource {
|
||||||
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
|
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
|
||||||
let HistoryTraversalTaskSource(ref chan) = *self;
|
self.0.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
|
||||||
chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone(&self) -> Box<ScriptChan + Send> {
|
fn clone(&self) -> Box<ScriptChan + Send> {
|
||||||
let HistoryTraversalTaskSource(ref chan) = *self;
|
box HistoryTraversalTaskSource((&self.0).clone())
|
||||||
box HistoryTraversalTaskSource((*chan).clone())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,10 @@ pub struct NetworkingTaskSource(pub Sender<MainThreadScriptMsg>);
|
||||||
|
|
||||||
impl ScriptChan for NetworkingTaskSource {
|
impl ScriptChan for NetworkingTaskSource {
|
||||||
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
|
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
|
||||||
let NetworkingTaskSource(ref chan) = *self;
|
self.0.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
|
||||||
chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone(&self) -> Box<ScriptChan + Send> {
|
fn clone(&self) -> Box<ScriptChan + Send> {
|
||||||
let NetworkingTaskSource(ref chan) = *self;
|
box NetworkingTaskSource((&self.0).clone())
|
||||||
box NetworkingTaskSource((*chan).clone())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,10 @@ pub struct UserInteractionTaskSource(pub Sender<MainThreadScriptMsg>);
|
||||||
|
|
||||||
impl ScriptChan for UserInteractionTaskSource {
|
impl ScriptChan for UserInteractionTaskSource {
|
||||||
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
|
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
|
||||||
let UserInteractionTaskSource(ref chan) = *self;
|
self.0.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
|
||||||
chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone(&self) -> Box<ScriptChan + Send> {
|
fn clone(&self) -> Box<ScriptChan + Send> {
|
||||||
let UserInteractionTaskSource(ref chan) = *self;
|
box UserInteractionTaskSource((&self.0).clone())
|
||||||
box UserInteractionTaskSource((*chan).clone())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,7 @@ impl OpaqueNode {
|
||||||
/// Returns the address of this node, for debugging purposes.
|
/// Returns the address of this node, for debugging purposes.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn id(&self) -> usize {
|
pub fn id(&self) -> usize {
|
||||||
let OpaqueNode(pointer) = *self;
|
self.0
|
||||||
pointer
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1077,10 +1077,9 @@ pub mod specified {
|
||||||
|
|
||||||
impl ToCss for BorderRadiusSize {
|
impl ToCss for BorderRadiusSize {
|
||||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
let BorderRadiusSize(size) = *self;
|
try!(self.0.width.to_css(dest));
|
||||||
try!(size.width.to_css(dest));
|
|
||||||
try!(dest.write_str(" "));
|
try!(dest.write_str(" "));
|
||||||
size.height.to_css(dest)
|
self.0.height.to_css(dest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1133,8 +1132,7 @@ pub mod specified {
|
||||||
|
|
||||||
impl ToCss for Angle {
|
impl ToCss for Angle {
|
||||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
let Angle(value) = *self;
|
write!(dest, "{}rad", self.0)
|
||||||
write!(dest, "{}rad", value)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1642,19 +1640,17 @@ pub mod computed {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_computed_value<Cx: TContext>(&self, context: &Cx) -> BorderRadiusSize {
|
fn to_computed_value<Cx: TContext>(&self, context: &Cx) -> BorderRadiusSize {
|
||||||
let specified::BorderRadiusSize(s) = *self;
|
let w = self.0.width.to_computed_value(context);
|
||||||
let w = s.width.to_computed_value(context);
|
let h = self.0.height.to_computed_value(context);
|
||||||
let h = s.height.to_computed_value(context);
|
|
||||||
BorderRadiusSize(Size2D::new(w, h))
|
BorderRadiusSize(Size2D::new(w, h))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::cssparser::ToCss for BorderRadiusSize {
|
impl ::cssparser::ToCss for BorderRadiusSize {
|
||||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
let BorderRadiusSize(s) = *self;
|
try!(self.0.width.to_css(dest));
|
||||||
try!(s.width.to_css(dest));
|
|
||||||
try!(dest.write_str("/"));
|
try!(dest.write_str("/"));
|
||||||
s.height.to_css(dest)
|
self.0.height.to_css(dest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue