Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Get rid of a bunch of explicit derefs
  • Loading branch information
dzbarsky committed Nov 4, 2015
1 parent ca56ebb commit 722aa86
Show file tree
Hide file tree
Showing 49 changed files with 340 additions and 360 deletions.
10 changes: 5 additions & 5 deletions components/script/devtools.rs
Expand Up @@ -67,7 +67,7 @@ pub fn handle_get_root_node(page: &Rc<Page>, pipeline: PipelineId, reply: IpcSen
pub fn handle_get_document_element(page: &Rc<Page>, pipeline: PipelineId, reply: IpcSender<NodeInfo>) {
let page = get_page(&*page, pipeline);
let document = page.document();
let document_element = document.r().GetDocumentElement().unwrap();
let document_element = document.GetDocumentElement().unwrap();

let node = document_element.upcast::<Node>();
reply.send(node.summarize()).unwrap();
Expand All @@ -79,7 +79,7 @@ fn find_node_by_unique_id(page: &Rc<Page>, pipeline: PipelineId, node_id: String
let node = document.upcast::<Node>();

for candidate in node.traverse_preorder() {
if candidate.r().get_unique_id() == node_id {
if candidate.get_unique_id() == node_id {
return candidate;
}
}
Expand All @@ -89,8 +89,8 @@ fn find_node_by_unique_id(page: &Rc<Page>, pipeline: PipelineId, node_id: String

pub fn handle_get_children(page: &Rc<Page>, pipeline: PipelineId, node_id: String, reply: IpcSender<Vec<NodeInfo>>) {
let parent = find_node_by_unique_id(&*page, pipeline, node_id);
let children = parent.r().children().map(|child| {
child.r().summarize()
let children = parent.children().map(|child| {
child.summarize()
}).collect();
reply.send(children).unwrap();
}
Expand Down Expand Up @@ -187,7 +187,7 @@ pub fn handle_request_animation_frame(page: &Rc<Page>, id: PipelineId, actor_nam
let page = page.find(id).expect("There is no such page");
let doc = page.document();
let devtools_sender = page.window().devtools_chan().unwrap();
doc.r().request_animation_frame(box move |time| {
doc.request_animation_frame(box move |time| {
let msg = ScriptToDevtoolsControlMsg::FramerateTick(actor_name, time);
devtools_sender.send(msg).unwrap();
});
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/attr.rs
Expand Up @@ -225,7 +225,7 @@ impl AttrMethods for Attr {
match self.owner() {
None => *self.value.borrow_mut() = AttrValue::String(value),
Some(owner) => {
let value = owner.r().parse_attribute(&self.namespace, self.local_name(), value);
let value = owner.parse_attribute(&self.namespace, self.local_name(), value);
self.set_value(value, owner.r());
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/bindings/conversions.rs
Expand Up @@ -760,7 +760,7 @@ pub fn native_from_handleobject<T>(obj: HandleObject) -> Result<Root<T>, ()>

impl<T: Reflectable> ToJSValConvertible for Root<T> {
fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
self.r().reflector().to_jsval(cx, rval);
self.reflector().to_jsval(cx, rval);
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/bindings/js.rs
Expand Up @@ -491,7 +491,7 @@ impl RootCollection {
debug_assert!(task_state::get().is_script());
unsafe {
let mut roots = &mut *self.roots.get();
let old_reflector = &*rooted.r().reflector();
let old_reflector = &*rooted.reflector();
match roots.iter().rposition(|r| *r == old_reflector) {
Some(idx) => {
roots.remove(idx);
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/browsercontext.rs
Expand Up @@ -106,7 +106,7 @@ unsafe fn GetSubframeWindow(cx: *mut JSContext, proxy: HandleObject, id: HandleI
let target = RootedObject::new(cx, GetProxyPrivate(*proxy.ptr).to_object());
let win: Root<Window> = native_from_handleobject(target.handle()).unwrap();
let mut found = false;
return win.r().IndexedGetter(index, &mut found);
return win.IndexedGetter(index, &mut found);
}

None
Expand Down
15 changes: 6 additions & 9 deletions components/script/dom/canvasrenderingcontext2d.rs
Expand Up @@ -298,7 +298,7 @@ impl CanvasRenderingContext2D {
None => return Err(Error::InvalidState),
};

let renderer = context.r().get_ipc_renderer();
let renderer = context.get_ipc_renderer();
let (sender, receiver) = ipc::channel::<Vec<u8>>().unwrap();
// Reads pixels from source image
renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::GetImageData(source_rect.to_i32(),
Expand Down Expand Up @@ -787,7 +787,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
self.state.borrow_mut().stroke_style = CanvasFillOrStrokeStyle::Gradient(
JS::from_ref(gradient.r()));
let msg = CanvasMsg::Canvas2d(
Canvas2dMsg::SetStrokeStyle(gradient.r().to_fill_or_stroke_style()));
Canvas2dMsg::SetStrokeStyle(gradient.to_fill_or_stroke_style()));
self.ipc_renderer.send(msg).unwrap();
},
_ => {}
Expand Down Expand Up @@ -824,12 +824,12 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
self.state.borrow_mut().fill_style = CanvasFillOrStrokeStyle::Gradient(
JS::from_rooted(&gradient));
let msg = CanvasMsg::Canvas2d(
Canvas2dMsg::SetFillStyle(gradient.r().to_fill_or_stroke_style()));
Canvas2dMsg::SetFillStyle(gradient.to_fill_or_stroke_style()));
self.ipc_renderer.send(msg).unwrap();
}
StringOrCanvasGradientOrCanvasPattern::eCanvasPattern(pattern) => {
self.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::SetFillStyle(
pattern.r().to_fill_or_stroke_style()))).unwrap();
pattern.to_fill_or_stroke_style()))).unwrap();
}
}
}
Expand Down Expand Up @@ -944,17 +944,15 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
repetition: DOMString) -> Fallible<Root<CanvasPattern>> {
let (image_data, image_size) = match image {
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::eHTMLImageElement(image) => {
let image_element = image.r();
// https://html.spec.whatwg.org/multipage/#img-error
// If the image argument is an HTMLImageElement object that is in the broken state,
// then throw an InvalidStateError exception
match self.fetch_image_data(&image_element) {
match self.fetch_image_data(&image.r()) {
Some((data, size)) => (data, size),
None => return Err(Error::InvalidState),
}
},
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::eHTMLCanvasElement(canvas) => {
let canvas = canvas.r();
let _ = canvas.get_or_init_2d_context();

match canvas.fetch_all_data() {
Expand All @@ -963,8 +961,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
}
},
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::eCanvasRenderingContext2D(context) => {
let canvas = context.r().Canvas();
let canvas = canvas.r();
let canvas = context.Canvas();
let _ = canvas.get_or_init_2d_context();

match canvas.fetch_all_data() {
Expand Down
3 changes: 1 addition & 2 deletions components/script/dom/characterdata.rs
Expand Up @@ -156,8 +156,7 @@ impl CharacterData {

fn content_changed(&self) {
let node = self.upcast::<Node>();
let document = node.owner_doc();
document.r().content_changed(node, NodeDamage::OtherNodeDamage);
node.owner_doc().content_changed(node, NodeDamage::OtherNodeDamage);
}
}

Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/cssstyledeclaration.rs
Expand Up @@ -216,7 +216,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {

// Step 6
let window = window_from_node(&*self.owner);
let declarations = parse_one_declaration(&property, &value, &window.r().get_url());
let declarations = parse_one_declaration(&property, &value, &window.get_url());

// Step 7
let declarations = if let Ok(declarations) = declarations {
Expand All @@ -235,7 +235,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {

let document = document_from_node(element);
let node = element.upcast();
document.r().content_changed(node, NodeDamage::NodeStyleDamaged);
document.content_changed(node, NodeDamage::NodeStyleDamaged);
Ok(())
}

Expand Down Expand Up @@ -268,7 +268,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {

let document = document_from_node(element);
let node = element.upcast();
document.r().content_changed(node, NodeDamage::NodeStyleDamaged);
document.content_changed(node, NodeDamage::NodeStyleDamaged);
Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/customevent.rs
Expand Up @@ -42,7 +42,7 @@ impl CustomEvent {
cancelable: bool,
detail: HandleValue) -> Root<CustomEvent> {
let ev = CustomEvent::new_uninitialized(global);
ev.r().InitCustomEvent(global.get_cx(), type_, bubbles, cancelable, detail);
ev.InitCustomEvent(global.get_cx(), type_, bubbles, cancelable, detail);
ev
}
#[allow(unsafe_code)]
Expand Down

0 comments on commit 722aa86

Please sign in to comment.