fix: sync api::Screen wrapper method sigs to upstream (#38597)

refactor: sync api::Screen getter sigs to upstream

ui::Display GetAllDisplays(), GetPrimaryDisplay(), GetDisplayMatching(),
and GetDisplayNearestPoint() methods are all const, so make our wrappers
const too.

ui::Display GetAllDisplays() returns a const reference, so make our
wrapper return a const reference too. This avoids creating a new
std::vector<display::Display> each time it's called.
This commit is contained in:
Charles Kerr 2023-06-07 02:28:50 -05:00 committed by GitHub
parent 80246cf97f
commit 5931f69f18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 20 deletions

View file

@ -87,22 +87,6 @@ gfx::Point Screen::GetCursorScreenPoint(v8::Isolate* isolate) {
return screen_->GetCursorScreenPoint();
}
display::Display Screen::GetPrimaryDisplay() {
return screen_->GetPrimaryDisplay();
}
std::vector<display::Display> Screen::GetAllDisplays() {
return screen_->GetAllDisplays();
}
display::Display Screen::GetDisplayNearestPoint(const gfx::Point& point) {
return screen_->GetDisplayNearestPoint(point);
}
display::Display Screen::GetDisplayMatching(const gfx::Rect& match_rect) {
return screen_->GetDisplayMatching(match_rect);
}
#if BUILDFLAG(IS_WIN)
static gfx::Rect ScreenToDIPRect(electron::NativeWindow* window,

View file

@ -42,10 +42,18 @@ class Screen : public gin::Wrappable<Screen>,
~Screen() override;
gfx::Point GetCursorScreenPoint(v8::Isolate* isolate);
display::Display GetPrimaryDisplay();
std::vector<display::Display> GetAllDisplays();
display::Display GetDisplayNearestPoint(const gfx::Point& point);
display::Display GetDisplayMatching(const gfx::Rect& match_rect);
display::Display GetPrimaryDisplay() const {
return screen_->GetPrimaryDisplay();
}
const std::vector<display::Display>& GetAllDisplays() const {
return screen_->GetAllDisplays();
}
display::Display GetDisplayNearestPoint(const gfx::Point& point) const {
return screen_->GetDisplayNearestPoint(point);
}
display::Display GetDisplayMatching(const gfx::Rect& match_rect) const {
return screen_->GetDisplayMatching(match_rect);
}
// display::DisplayObserver:
void OnDisplayAdded(const display::Display& new_display) override;