Skip to content

Commit 0760e56

Browse files
author
bors-servo
committed
Auto merge of servo#10327 - frewsxcv:get-prefix, r=ms2ger
Remove `get_*` on getters as per RFC 0344. https://github.com/rust-lang/rfcs/blob/master/text/0344-conventions-galore.md#gettersetter-apis servo#6224 <!-- 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/10327) <!-- Reviewable:end -->
2 parents f2b48d2 + bf4db40 commit 0760e56

File tree

9 files changed

+35
-35
lines changed

9 files changed

+35
-35
lines changed

components/script/devtools.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn find_node_by_unique_id(page: &Rc<Page>, pipeline: PipelineId, node_id: String
9191
let node = document.upcast::<Node>();
9292

9393
for candidate in node.traverse_preorder() {
94-
if candidate.get_unique_id() == node_id {
94+
if candidate.unique_id() == node_id {
9595
return candidate;
9696
}
9797
}

components/script/dom/document.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ impl Document {
356356
// that workable.
357357
match self.GetDocumentElement() {
358358
Some(root) => {
359-
root.upcast::<Node>().get_has_dirty_descendants() ||
359+
root.upcast::<Node>().has_dirty_descendants() ||
360360
!self.modified_elements.borrow().is_empty()
361361
}
362362
None => false,

components/script/dom/element.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,7 @@ impl ElementMethods for Element {
14311431
// https://drafts.csswg.org/cssom-view/#dom-element-getclientrects
14321432
fn GetClientRects(&self) -> Root<DOMRectList> {
14331433
let win = window_from_node(self);
1434-
let raw_rects = self.upcast::<Node>().get_content_boxes();
1434+
let raw_rects = self.upcast::<Node>().content_boxes();
14351435
let rects = raw_rects.iter().map(|rect| {
14361436
DOMRect::new(GlobalRef::Window(win.r()),
14371437
rect.origin.x.to_f64_px(),
@@ -1445,7 +1445,7 @@ impl ElementMethods for Element {
14451445
// https://drafts.csswg.org/cssom-view/#dom-element-getboundingclientrect
14461446
fn GetBoundingClientRect(&self) -> Root<DOMRect> {
14471447
let win = window_from_node(self);
1448-
let rect = self.upcast::<Node>().get_bounding_content_box();
1448+
let rect = self.upcast::<Node>().bounding_content_box();
14491449
DOMRect::new(GlobalRef::Window(win.r()),
14501450
rect.origin.x.to_f64_px(),
14511451
rect.origin.y.to_f64_px(),
@@ -1455,32 +1455,32 @@ impl ElementMethods for Element {
14551455

14561456
// https://drafts.csswg.org/cssom-view/#dom-element-scrollwidth
14571457
fn ScrollWidth(&self) -> i32 {
1458-
self.upcast::<Node>().get_scroll_area().size.width
1458+
self.upcast::<Node>().scroll_area().size.width
14591459
}
14601460

14611461
// https://drafts.csswg.org/cssom-view/#dom-element-scrollheight
14621462
fn ScrollHeight(&self) -> i32 {
1463-
self.upcast::<Node>().get_scroll_area().size.height
1463+
self.upcast::<Node>().scroll_area().size.height
14641464
}
14651465

14661466
// https://drafts.csswg.org/cssom-view/#dom-element-clienttop
14671467
fn ClientTop(&self) -> i32 {
1468-
self.upcast::<Node>().get_client_rect().origin.y
1468+
self.upcast::<Node>().client_rect().origin.y
14691469
}
14701470

14711471
// https://drafts.csswg.org/cssom-view/#dom-element-clientleft
14721472
fn ClientLeft(&self) -> i32 {
1473-
self.upcast::<Node>().get_client_rect().origin.x
1473+
self.upcast::<Node>().client_rect().origin.x
14741474
}
14751475

14761476
// https://drafts.csswg.org/cssom-view/#dom-element-clientwidth
14771477
fn ClientWidth(&self) -> i32 {
1478-
self.upcast::<Node>().get_client_rect().size.width
1478+
self.upcast::<Node>().client_rect().size.width
14791479
}
14801480

14811481
// https://drafts.csswg.org/cssom-view/#dom-element-clientheight
14821482
fn ClientHeight(&self) -> i32 {
1483-
self.upcast::<Node>().get_client_rect().size.height
1483+
self.upcast::<Node>().client_rect().size.height
14841484
}
14851485

14861486
/// https://w3c.github.io/DOM-Parsing/#widl-Element-innerHTML

components/script/dom/htmlcollection.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl HTMLCollection {
7272
root: JS::from_ref(root),
7373
filter: filter,
7474
// Default values for the cache
75-
cached_version: Cell::new(root.get_inclusive_descendants_version()),
75+
cached_version: Cell::new(root.inclusive_descendants_version()),
7676
cached_cursor_element: MutNullableHeap::new(None),
7777
cached_cursor_index: Cell::new(OptionU32::none()),
7878
cached_length: Cell::new(OptionU32::none()),
@@ -93,7 +93,7 @@ impl HTMLCollection {
9393
fn validate_cache(&self) {
9494
// Clear the cache if the root version is different from our cached version
9595
let cached_version = self.cached_version.get();
96-
let curr_version = self.root.get_inclusive_descendants_version();
96+
let curr_version = self.root.inclusive_descendants_version();
9797
if curr_version != cached_version {
9898
// Default values for the cache
9999
self.cached_version.set(curr_version);

components/script/dom/htmlimageelement.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ impl HTMLImageElementMethods for HTMLImageElement {
236236
// https://html.spec.whatwg.org/multipage/#dom-img-width
237237
fn Width(&self) -> u32 {
238238
let node = self.upcast::<Node>();
239-
let rect = node.get_bounding_content_box();
239+
let rect = node.bounding_content_box();
240240
rect.size.width.to_px() as u32
241241
}
242242

@@ -248,7 +248,7 @@ impl HTMLImageElementMethods for HTMLImageElement {
248248
// https://html.spec.whatwg.org/multipage/#dom-img-height
249249
fn Height(&self) -> u32 {
250250
let node = self.upcast::<Node>();
251-
let rect = node.get_bounding_content_box();
251+
let rect = node.bounding_content_box();
252252
rect.size.height.to_px() as u32
253253
}
254254

components/script/dom/node.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -420,23 +420,23 @@ impl Node {
420420
self.flags.set(flags);
421421
}
422422

423-
pub fn get_has_changed(&self) -> bool {
423+
pub fn has_changed(&self) -> bool {
424424
self.get_flag(HAS_CHANGED)
425425
}
426426

427427
pub fn set_has_changed(&self, state: bool) {
428428
self.set_flag(HAS_CHANGED, state)
429429
}
430430

431-
pub fn get_is_dirty(&self) -> bool {
431+
pub fn is_dirty(&self) -> bool {
432432
self.get_flag(IS_DIRTY)
433433
}
434434

435435
pub fn set_is_dirty(&self, state: bool) {
436436
self.set_flag(IS_DIRTY, state)
437437
}
438438

439-
pub fn get_has_dirty_descendants(&self) -> bool {
439+
pub fn has_dirty_descendants(&self) -> bool {
440440
self.get_flag(HAS_DIRTY_DESCENDANTS)
441441
}
442442

@@ -454,7 +454,7 @@ impl Node {
454454
// the document's version, but we do have to deal with the case where the node has moved
455455
// document, so may have a higher version count than its owning document.
456456
let doc: Root<Node> = Root::upcast(self.owner_doc());
457-
let version = max(self.get_inclusive_descendants_version(), doc.get_inclusive_descendants_version()) + 1;
457+
let version = max(self.inclusive_descendants_version(), doc.inclusive_descendants_version()) + 1;
458458
for ancestor in self.inclusive_ancestors() {
459459
ancestor.inclusive_descendants_version.set(version);
460460
}
@@ -475,14 +475,14 @@ impl Node {
475475
NodeDamage::OtherNodeDamage => self.set_has_changed(true),
476476
}
477477

478-
if self.get_is_dirty() && !force_ancestors {
478+
if self.is_dirty() && !force_ancestors {
479479
return
480480
}
481481

482482
// 2. Dirty descendants.
483483
fn dirty_subtree(node: &Node) {
484484
// Stop if this subtree is already dirty.
485-
if node.get_is_dirty() { return }
485+
if node.is_dirty() { return }
486486

487487
node.set_flag(IS_DIRTY | HAS_DIRTY_DESCENDANTS, true);
488488

@@ -495,13 +495,13 @@ impl Node {
495495

496496
// 4. Dirty ancestors.
497497
for ancestor in self.ancestors() {
498-
if !force_ancestors && ancestor.get_has_dirty_descendants() { break }
498+
if !force_ancestors && ancestor.has_dirty_descendants() { break }
499499
ancestor.set_has_dirty_descendants(true);
500500
}
501501
}
502502

503503
/// The maximum version number of this node's descendants, including itself
504-
pub fn get_inclusive_descendants_version(&self) -> u64 {
504+
pub fn inclusive_descendants_version(&self) -> u64 {
505505
self.inclusive_descendants_version.get()
506506
}
507507

@@ -570,23 +570,23 @@ impl Node {
570570
TrustedNodeAddress(&*self as *const Node as *const libc::c_void)
571571
}
572572

573-
pub fn get_bounding_content_box(&self) -> Rect<Au> {
573+
pub fn bounding_content_box(&self) -> Rect<Au> {
574574
window_from_node(self).content_box_query(self.to_trusted_node_address())
575575
}
576576

577-
pub fn get_content_boxes(&self) -> Vec<Rect<Au>> {
577+
pub fn content_boxes(&self) -> Vec<Rect<Au>> {
578578
window_from_node(self).content_boxes_query(self.to_trusted_node_address())
579579
}
580580

581-
pub fn get_client_rect(&self) -> Rect<i32> {
581+
pub fn client_rect(&self) -> Rect<i32> {
582582
window_from_node(self).client_rect_query(self.to_trusted_node_address())
583583
}
584584

585585
// https://drafts.csswg.org/cssom-view/#dom-element-scrollwidth
586586
// https://drafts.csswg.org/cssom-view/#dom-element-scrollheight
587587
// https://drafts.csswg.org/cssom-view/#dom-element-scrolltop
588588
// https://drafts.csswg.org/cssom-view/#dom-element-scrollleft
589-
pub fn get_scroll_area(&self) -> Rect<i32> {
589+
pub fn scroll_area(&self) -> Rect<i32> {
590590
// Step 1
591591
let document = self.owner_doc();
592592
// Step 3
@@ -798,15 +798,15 @@ impl Node {
798798
}
799799
}
800800

801-
pub fn get_unique_id(&self) -> String {
801+
pub fn unique_id(&self) -> String {
802802
self.unique_id.borrow().to_simple_string()
803803
}
804804

805805
pub fn summarize(&self) -> NodeInfo {
806806
NodeInfo {
807-
uniqueId: self.get_unique_id(),
807+
uniqueId: self.unique_id(),
808808
baseURI: String::from(self.BaseURI()),
809-
parent: self.GetParentNode().map_or("".to_owned(), |node| node.get_unique_id()),
809+
parent: self.GetParentNode().map_or("".to_owned(), |node| node.unique_id()),
810810
nodeType: self.NodeType(),
811811
namespaceURI: String::new(), //FIXME
812812
nodeName: String::from(self.NodeName()),

components/script/dom/window.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ impl Window {
890890
let body = self.Document().GetBody();
891891
let (x, y) = match body {
892892
Some(e) => {
893-
let content_size = e.upcast::<Node>().get_bounding_content_box();
893+
let content_size = e.upcast::<Node>().bounding_content_box();
894894
let content_height = content_size.size.height.to_f64_px();
895895
let content_width = content_size.size.width.to_f64_px();
896896
(xfinite.max(0.0f64).min(content_width - width),

components/script/script_thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1843,7 +1843,7 @@ impl ScriptThread {
18431843
// Really what needs to happen is that this needs to go through layout to ask which
18441844
// layer the element belongs to, and have it send the scroll message to the
18451845
// compositor.
1846-
let rect = element.upcast::<Node>().get_bounding_content_box();
1846+
let rect = element.upcast::<Node>().bounding_content_box();
18471847

18481848
// In order to align with element edges, we snap to unscaled pixel boundaries, since the
18491849
// paint thread currently does the same for drawing elements. This is important for pages

components/script/webdriver_handlers.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use util::str::DOMString;
4040
fn find_node_by_unique_id(page: &Rc<Page>, pipeline: PipelineId, node_id: String) -> Option<Root<Node>> {
4141
let page = get_page(&*page, pipeline);
4242
let document = page.document();
43-
document.upcast::<Node>().traverse_preorder().find(|candidate| candidate.get_unique_id() == node_id)
43+
document.upcast::<Node>().traverse_preorder().find(|candidate| candidate.unique_id() == node_id)
4444
}
4545

4646
#[allow(unsafe_code)]
@@ -124,7 +124,7 @@ pub fn handle_find_element_css(page: &Rc<Page>, _pipeline: PipelineId, selector:
124124
reply: IpcSender<Result<Option<String>, ()>>) {
125125
reply.send(match page.document().QuerySelector(DOMString::from(selector)) {
126126
Ok(node) => {
127-
Ok(node.map(|x| x.upcast::<Node>().get_unique_id()))
127+
Ok(node.map(|x| x.upcast::<Node>().unique_id()))
128128
}
129129
Err(_) => Err(())
130130
}).unwrap();
@@ -139,7 +139,7 @@ pub fn handle_find_elements_css(page: &Rc<Page>,
139139
let mut result = Vec::with_capacity(nodes.Length() as usize);
140140
for i in 0..nodes.Length() {
141141
if let Some(ref node) = nodes.Item(i) {
142-
result.push(node.get_unique_id());
142+
result.push(node.unique_id());
143143
}
144144
}
145145
Ok(result)
@@ -173,7 +173,7 @@ pub fn handle_get_active_element(page: &Rc<Page>,
173173
_pipeline: PipelineId,
174174
reply: IpcSender<Option<String>>) {
175175
reply.send(page.document().GetActiveElement().map(
176-
|elem| elem.upcast::<Node>().get_unique_id())).unwrap();
176+
|elem| elem.upcast::<Node>().unique_id())).unwrap();
177177
}
178178

179179
pub fn handle_get_title(page: &Rc<Page>, _pipeline: PipelineId, reply: IpcSender<String>) {

0 commit comments

Comments
 (0)