Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of a bunch of explicit derefs #8305

Merged
merged 1 commit into from Nov 4, 2015
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -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)]
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.