Skip to content
Permalink
Browse files

Get rid of a bunch of explicit derefs

  • Loading branch information
dzbarsky committed Nov 4, 2015
1 parent ca56ebb commit 722aa86c895b42798d60bcada41b0175dbafba52
Showing with 340 additions and 360 deletions.
  1. +5 −5 components/script/devtools.rs
  2. +1 −1 components/script/dom/attr.rs
  3. +1 −1 components/script/dom/bindings/conversions.rs
  4. +1 −1 components/script/dom/bindings/js.rs
  5. +1 −1 components/script/dom/browsercontext.rs
  6. +6 −9 components/script/dom/canvasrenderingcontext2d.rs
  7. +1 −2 components/script/dom/characterdata.rs
  8. +3 −3 components/script/dom/cssstyledeclaration.rs
  9. +1 −1 components/script/dom/customevent.rs
  10. +40 −40 components/script/dom/document.rs
  11. +1 −1 components/script/dom/domimplementation.rs
  12. +1 −1 components/script/dom/domparser.rs
  13. +21 −21 components/script/dom/element.rs
  14. +1 −1 components/script/dom/event.rs
  15. +2 −2 components/script/dom/htmlanchorelement.rs
  16. +7 −11 components/script/dom/htmlbodyelement.rs
  17. +4 −4 components/script/dom/htmlbuttonelement.rs
  18. +2 −2 components/script/dom/htmlcollection.rs
  19. +9 −12 components/script/dom/htmlelement.rs
  20. +1 −1 components/script/dom/htmlfieldsetelement.rs
  21. +10 −10 components/script/dom/htmlformelement.rs
  22. +7 −7 components/script/dom/htmliframeelement.rs
  23. +2 −2 components/script/dom/htmlimageelement.rs
  24. +13 −15 components/script/dom/htmlinputelement.rs
  25. +2 −2 components/script/dom/htmllinkelement.rs
  26. +1 −1 components/script/dom/htmlmetaelement.rs
  27. +18 −18 components/script/dom/htmlscriptelement.rs
  28. +1 −1 components/script/dom/htmlselectelement.rs
  29. +1 −2 components/script/dom/htmlstyleelement.rs
  30. +1 −1 components/script/dom/htmltextareaelement.rs
  31. +1 −2 components/script/dom/htmltitleelement.rs
  32. +2 −2 components/script/dom/keyboardevent.rs
  33. +1 −1 components/script/dom/macros.rs
  34. +5 −5 components/script/dom/mouseevent.rs
  35. +49 −49 components/script/dom/node.rs
  36. +2 −2 components/script/dom/nodeiterator.rs
  37. +2 −2 components/script/dom/range.rs
  38. +4 −4 components/script/dom/servohtmlparser.rs
  39. +4 −4 components/script/dom/text.rs
  40. +3 −3 components/script/dom/treewalker.rs
  41. +2 −2 components/script/dom/uievent.rs
  42. +2 −2 components/script/dom/urlsearchparams.rs
  43. +3 −3 components/script/dom/webglrenderingcontext.rs
  44. +1 −1 components/script/dom/websocket.rs
  45. +6 −8 components/script/dom/window.rs
  46. +10 −13 components/script/dom/xmlhttprequest.rs
  47. +7 −7 components/script/parse/html.rs
  48. +53 −53 components/script/script_task.rs
  49. +18 −18 components/script/webdriver_handlers.rs
@@ -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();
@@ -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;
}
}
@@ -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();
}
@@ -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();
});
@@ -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());
}
}
@@ -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);
}
}

@@ -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);
@@ -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
@@ -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(),
@@ -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();
},
_ => {}
@@ -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();
}
}
}
@@ -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() {
@@ -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() {
@@ -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);
}
}

@@ -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 {
@@ -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(())
}

@@ -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(())
}

@@ -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)]

0 comments on commit 722aa86

Please sign in to comment.
You can’t perform that action at this time.