mirror of
https://github.com/servo/servo.git
synced 2025-06-25 09:34:32 +01:00
More code refactoring (exampleVar to example_var)
This commit is contained in:
parent
5fa54177ca
commit
dbec9d8454
5 changed files with 38 additions and 38 deletions
|
@ -230,7 +230,7 @@ impl SessionHistoryEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn GetSubframeWindow(cx: *mut JSContext,
|
unsafe fn get_subframe_window(cx: *mut JSContext,
|
||||||
proxy: HandleObject,
|
proxy: HandleObject,
|
||||||
id: HandleId)
|
id: HandleId)
|
||||||
-> Option<Root<Window>> {
|
-> Option<Root<Window>> {
|
||||||
|
@ -251,7 +251,7 @@ unsafe extern "C" fn getOwnPropertyDescriptor(cx: *mut JSContext,
|
||||||
id: HandleId,
|
id: HandleId,
|
||||||
mut desc: MutableHandle<PropertyDescriptor>)
|
mut desc: MutableHandle<PropertyDescriptor>)
|
||||||
-> bool {
|
-> bool {
|
||||||
let window = GetSubframeWindow(cx, proxy, id);
|
let window = get_subframe_window(cx, proxy, id);
|
||||||
if let Some(window) = window {
|
if let Some(window) = window {
|
||||||
rooted!(in(cx) let mut val = UndefinedValue());
|
rooted!(in(cx) let mut val = UndefinedValue());
|
||||||
window.to_jsval(cx, val.handle_mut());
|
window.to_jsval(cx, val.handle_mut());
|
||||||
|
@ -300,7 +300,7 @@ unsafe extern "C" fn has(cx: *mut JSContext,
|
||||||
id: HandleId,
|
id: HandleId,
|
||||||
bp: *mut bool)
|
bp: *mut bool)
|
||||||
-> bool {
|
-> bool {
|
||||||
let window = GetSubframeWindow(cx, proxy, id);
|
let window = get_subframe_window(cx, proxy, id);
|
||||||
if window.is_some() {
|
if window.is_some() {
|
||||||
*bp = true;
|
*bp = true;
|
||||||
return true;
|
return true;
|
||||||
|
@ -323,7 +323,7 @@ unsafe extern "C" fn get(cx: *mut JSContext,
|
||||||
id: HandleId,
|
id: HandleId,
|
||||||
vp: MutableHandleValue)
|
vp: MutableHandleValue)
|
||||||
-> bool {
|
-> bool {
|
||||||
let window = GetSubframeWindow(cx, proxy, id);
|
let window = get_subframe_window(cx, proxy, id);
|
||||||
if let Some(window) = window {
|
if let Some(window) = window {
|
||||||
window.to_jsval(cx, vp);
|
window.to_jsval(cx, vp);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1096,16 +1096,16 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
imagedata: &ImageData,
|
imagedata: &ImageData,
|
||||||
dx: Finite<f64>,
|
dx: Finite<f64>,
|
||||||
dy: Finite<f64>,
|
dy: Finite<f64>,
|
||||||
dirtyX: Finite<f64>,
|
dirty_x: Finite<f64>,
|
||||||
dirtyY: Finite<f64>,
|
dirty_y: Finite<f64>,
|
||||||
dirtyWidth: Finite<f64>,
|
dirty_width: Finite<f64>,
|
||||||
dirtyHeight: Finite<f64>) {
|
dirty_height: Finite<f64>) {
|
||||||
let data = imagedata.get_data_array();
|
let data = imagedata.get_data_array();
|
||||||
let offset = Point2D::new(*dx, *dy);
|
let offset = Point2D::new(*dx, *dy);
|
||||||
let image_data_size = Size2D::new(imagedata.Width() as f64, imagedata.Height() as f64);
|
let image_data_size = Size2D::new(imagedata.Width() as f64, imagedata.Height() as f64);
|
||||||
|
|
||||||
let dirty_rect = Rect::new(Point2D::new(*dirtyX, *dirtyY),
|
let dirty_rect = Rect::new(Point2D::new(*dirty_x, *dirty_y),
|
||||||
Size2D::new(*dirtyWidth, *dirtyHeight));
|
Size2D::new(*dirty_width, *dirty_height));
|
||||||
let msg = CanvasMsg::Canvas2d(Canvas2dMsg::PutImageData(data,
|
let msg = CanvasMsg::Canvas2d(Canvas2dMsg::PutImageData(data,
|
||||||
offset,
|
offset,
|
||||||
image_data_size,
|
image_data_size,
|
||||||
|
|
|
@ -17,16 +17,16 @@ use string_cache::Atom;
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct CloseEvent {
|
pub struct CloseEvent {
|
||||||
event: Event,
|
event: Event,
|
||||||
wasClean: bool,
|
was_clean: bool,
|
||||||
code: u16,
|
code: u16,
|
||||||
reason: DOMString,
|
reason: DOMString,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CloseEvent {
|
impl CloseEvent {
|
||||||
pub fn new_inherited(wasClean: bool, code: u16, reason: DOMString) -> CloseEvent {
|
pub fn new_inherited(was_clean: bool, code: u16, reason: DOMString) -> CloseEvent {
|
||||||
CloseEvent {
|
CloseEvent {
|
||||||
event: Event::new_inherited(),
|
event: Event::new_inherited(),
|
||||||
wasClean: wasClean,
|
was_clean: was_clean,
|
||||||
code: code,
|
code: code,
|
||||||
reason: reason,
|
reason: reason,
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ impl CloseEvent {
|
||||||
impl CloseEventMethods for CloseEvent {
|
impl CloseEventMethods for CloseEvent {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-closeevent-wasclean
|
// https://html.spec.whatwg.org/multipage/#dom-closeevent-wasclean
|
||||||
fn WasClean(&self) -> bool {
|
fn WasClean(&self) -> bool {
|
||||||
self.wasClean
|
self.was_clean
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-closeevent-code
|
// https://html.spec.whatwg.org/multipage/#dom-closeevent-code
|
||||||
|
|
|
@ -101,11 +101,11 @@ fn timestamp_in_ms(time: Timespec) -> u64 {
|
||||||
(time.sec * 1000 + (time.nsec / 1000000) as i64) as u64
|
(time.sec * 1000 + (time.nsec / 1000000) as i64) as u64
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_message(logLevel: LogLevel, message: DOMString) -> ConsoleMessage {
|
fn prepare_message(log_level: LogLevel, message: DOMString) -> ConsoleMessage {
|
||||||
// TODO: Sending fake values for filename, lineNumber and columnNumber in LogMessage; adjust later
|
// TODO: Sending fake values for filename, lineNumber and columnNumber in LogMessage; adjust later
|
||||||
ConsoleMessage {
|
ConsoleMessage {
|
||||||
message: String::from(message),
|
message: String::from(message),
|
||||||
logLevel: logLevel,
|
logLevel: log_level,
|
||||||
filename: "test".to_owned(),
|
filename: "test".to_owned(),
|
||||||
lineNumber: 1,
|
lineNumber: 1,
|
||||||
columnNumber: 1,
|
columnNumber: 1,
|
||||||
|
|
|
@ -733,13 +733,13 @@ impl Document {
|
||||||
// https://w3c.github.io/uievents/#event-type-click
|
// https://w3c.github.io/uievents/#event-type-click
|
||||||
let client_x = client_point.x as i32;
|
let client_x = client_point.x as i32;
|
||||||
let client_y = client_point.y as i32;
|
let client_y = client_point.y as i32;
|
||||||
let clickCount = 1;
|
let click_count = 1;
|
||||||
let event = MouseEvent::new(&self.window,
|
let event = MouseEvent::new(&self.window,
|
||||||
DOMString::from(mouse_event_type_string),
|
DOMString::from(mouse_event_type_string),
|
||||||
EventBubbles::Bubbles,
|
EventBubbles::Bubbles,
|
||||||
EventCancelable::Cancelable,
|
EventCancelable::Cancelable,
|
||||||
Some(&self.window),
|
Some(&self.window),
|
||||||
clickCount,
|
click_count,
|
||||||
client_x,
|
client_x,
|
||||||
client_y,
|
client_y,
|
||||||
client_x,
|
client_x,
|
||||||
|
@ -804,7 +804,7 @@ impl Document {
|
||||||
if now.duration_since(last_time) < DBL_CLICK_TIMEOUT &&
|
if now.duration_since(last_time) < DBL_CLICK_TIMEOUT &&
|
||||||
dist < DBL_CLICK_DIST_THRESHOLD as f64 {
|
dist < DBL_CLICK_DIST_THRESHOLD as f64 {
|
||||||
// A double click has occurred if this click is within a certain time and dist. of previous click.
|
// A double click has occurred if this click is within a certain time and dist. of previous click.
|
||||||
let clickCount = 2;
|
let click_count = 2;
|
||||||
let client_x = click_pos.x as i32;
|
let client_x = click_pos.x as i32;
|
||||||
let client_y = click_pos.y as i32;
|
let client_y = click_pos.y as i32;
|
||||||
|
|
||||||
|
@ -813,7 +813,7 @@ impl Document {
|
||||||
EventBubbles::Bubbles,
|
EventBubbles::Bubbles,
|
||||||
EventCancelable::Cancelable,
|
EventCancelable::Cancelable,
|
||||||
Some(&self.window),
|
Some(&self.window),
|
||||||
clickCount,
|
click_count,
|
||||||
client_x,
|
client_x,
|
||||||
client_y,
|
client_y,
|
||||||
client_x,
|
client_x,
|
||||||
|
@ -1617,7 +1617,7 @@ impl Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#fire-a-focus-event
|
// https://html.spec.whatwg.org/multipage/#fire-a-focus-event
|
||||||
fn fire_focus_event(&self, focus_event_type: FocusEventType, node: &Node, relatedTarget: Option<&EventTarget>) {
|
fn fire_focus_event(&self, focus_event_type: FocusEventType, node: &Node, related_target: Option<&EventTarget>) {
|
||||||
let (event_name, does_bubble) = match focus_event_type {
|
let (event_name, does_bubble) = match focus_event_type {
|
||||||
FocusEventType::Focus => (DOMString::from("focus"), EventBubbles::DoesNotBubble),
|
FocusEventType::Focus => (DOMString::from("focus"), EventBubbles::DoesNotBubble),
|
||||||
FocusEventType::Blur => (DOMString::from("blur"), EventBubbles::DoesNotBubble),
|
FocusEventType::Blur => (DOMString::from("blur"), EventBubbles::DoesNotBubble),
|
||||||
|
@ -1628,7 +1628,7 @@ impl Document {
|
||||||
EventCancelable::NotCancelable,
|
EventCancelable::NotCancelable,
|
||||||
Some(&self.window),
|
Some(&self.window),
|
||||||
0i32,
|
0i32,
|
||||||
relatedTarget);
|
related_target);
|
||||||
let event = event.upcast::<Event>();
|
let event = event.upcast::<Event>();
|
||||||
event.set_trusted(true);
|
event.set_trusted(true);
|
||||||
let target = node.upcast();
|
let target = node.upcast();
|
||||||
|
@ -2380,10 +2380,10 @@ impl DocumentMethods for Document {
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createnodeiteratorroot-whattoshow-filter
|
// https://dom.spec.whatwg.org/#dom-document-createnodeiteratorroot-whattoshow-filter
|
||||||
fn CreateNodeIterator(&self,
|
fn CreateNodeIterator(&self,
|
||||||
root: &Node,
|
root: &Node,
|
||||||
whatToShow: u32,
|
what_to_show: u32,
|
||||||
filter: Option<Rc<NodeFilter>>)
|
filter: Option<Rc<NodeFilter>>)
|
||||||
-> Root<NodeIterator> {
|
-> Root<NodeIterator> {
|
||||||
NodeIterator::new(self, root, whatToShow, filter)
|
NodeIterator::new(self, root, what_to_show, filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/touch-events/#idl-def-Document
|
// https://w3c.github.io/touch-events/#idl-def-Document
|
||||||
|
@ -2391,22 +2391,22 @@ impl DocumentMethods for Document {
|
||||||
window: &Window,
|
window: &Window,
|
||||||
target: &EventTarget,
|
target: &EventTarget,
|
||||||
identifier: i32,
|
identifier: i32,
|
||||||
pageX: Finite<f64>,
|
page_x: Finite<f64>,
|
||||||
pageY: Finite<f64>,
|
page_y: Finite<f64>,
|
||||||
screenX: Finite<f64>,
|
screen_x: Finite<f64>,
|
||||||
screenY: Finite<f64>)
|
screen_y: Finite<f64>)
|
||||||
-> Root<Touch> {
|
-> Root<Touch> {
|
||||||
let clientX = Finite::wrap(*pageX - window.PageXOffset() as f64);
|
let client_x = Finite::wrap(*page_x - window.PageXOffset() as f64);
|
||||||
let clientY = Finite::wrap(*pageY - window.PageYOffset() as f64);
|
let client_y = Finite::wrap(*page_y - window.PageYOffset() as f64);
|
||||||
Touch::new(window,
|
Touch::new(window,
|
||||||
identifier,
|
identifier,
|
||||||
target,
|
target,
|
||||||
screenX,
|
screen_x,
|
||||||
screenY,
|
screen_y,
|
||||||
clientX,
|
client_x,
|
||||||
clientY,
|
client_y,
|
||||||
pageX,
|
page_x,
|
||||||
pageY)
|
page_y)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/touch-events/#idl-def-document-createtouchlist(touch...)
|
// https://w3c.github.io/touch-events/#idl-def-document-createtouchlist(touch...)
|
||||||
|
@ -2417,10 +2417,10 @@ impl DocumentMethods for Document {
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createtreewalker
|
// https://dom.spec.whatwg.org/#dom-document-createtreewalker
|
||||||
fn CreateTreeWalker(&self,
|
fn CreateTreeWalker(&self,
|
||||||
root: &Node,
|
root: &Node,
|
||||||
whatToShow: u32,
|
what_to_show: u32,
|
||||||
filter: Option<Rc<NodeFilter>>)
|
filter: Option<Rc<NodeFilter>>)
|
||||||
-> Root<TreeWalker> {
|
-> Root<TreeWalker> {
|
||||||
TreeWalker::new(self, root, whatToShow, filter)
|
TreeWalker::new(self, root, what_to_show, filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#document.title
|
// https://html.spec.whatwg.org/multipage/#document.title
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue