Skip to content

Commit

Permalink
Rename containsPoint to contains_point (#1375)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishtr authored Dec 26, 2024
1 parent 297365c commit f8dfbbe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions book/chrome.md
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ let's add a quick method to test whether a point is contained in a

``` {.python}
class Rect:
def containsPoint(self, x, y):
def contains_point(self, x, y):
return x >= self.left and x < self.right \
and y >= self.top and y < self.bottom
```
Expand All @@ -1008,11 +1008,11 @@ between clicking to add a tab or select an open tab.
``` {.python}
class Chrome:
def click(self, x, y):
if self.newtab_rect.containsPoint(x, y):
if self.newtab_rect.contains_point(x, y):
self.browser.new_tab(URL("https://browser.engineering/"))
else:
for i, tab in enumerate(self.browser.tabs):
if self.tab_rect(i).containsPoint(x, y):
if self.tab_rect(i).contains_point(x, y):
self.browser.active_tab = tab
break
```
Expand Down Expand Up @@ -1121,7 +1121,7 @@ invoke some method on the current tab to go back:
class Chrome:
def click(self, x, y):
# ...
elif self.back_rect.containsPoint(x, y):
elif self.back_rect.contains_point(x, y):
self.browser.active_tab.go_back()
```

Expand Down Expand Up @@ -1230,7 +1230,7 @@ class Chrome:
def click(self, x, y):
self.focus = None
# ...
elif self.address_rect.containsPoint(x, y):
elif self.address_rect.contains_point(x, y):
self.focus = "address bar"
self.address_bar = ""
```
Expand Down
10 changes: 5 additions & 5 deletions src/lab7.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def __init__(self, left, top, right, bottom):
self.right = right
self.bottom = bottom

def containsPoint(self, x, y):
def contains_point(self, x, y):
return x >= self.left and x < self.right \
and y >= self.top and y < self.bottom

Expand Down Expand Up @@ -463,16 +463,16 @@ def paint(self):

def click(self, x, y):
self.focus = None
if self.newtab_rect.containsPoint(x, y):
if self.newtab_rect.contains_point(x, y):
self.browser.new_tab(URL("https://browser.engineering/"))
elif self.back_rect.containsPoint(x, y):
elif self.back_rect.contains_point(x, y):
self.browser.active_tab.go_back()
elif self.address_rect.containsPoint(x, y):
elif self.address_rect.contains_point(x, y):
self.focus = "address bar"
self.address_bar = ""
else:
for i, tab in enumerate(self.browser.tabs):
if self.tab_rect(i).containsPoint(x, y):
if self.tab_rect(i).contains_point(x, y):
self.browser.active_tab = tab
break

Expand Down

0 comments on commit f8dfbbe

Please sign in to comment.