refactor: simplify some BaseWindow JS getters (#46565)

* refactor: return a std::array<int 2> from BaseWindow::GetMaximumSize()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: return a std::array<int 2> from BaseWindow::GetMinimumSize()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: return a std::array<int 2> from BaseWindow::GetPosition()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: return a std::array<int 2> from BaseWindow::GetSize()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: return a std::array<int 2> from BaseWindow::GetContentSize()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: extract helper method ToArray(const gfx::Size)

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: #include correctness

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
trop[bot] 2025-04-08 13:44:15 -05:00 committed by GitHub
parent feaa9ec5b9
commit 3fdcd38b8b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 25 additions and 35 deletions

View file

@ -5,6 +5,7 @@
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_BASE_WINDOW_H_
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_BASE_WINDOW_H_
#include <array>
#include <map>
#include <memory>
#include <optional>
@ -119,17 +120,17 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
void SetBounds(const gfx::Rect& bounds, gin_helper::Arguments* args);
gfx::Rect GetBounds() const;
void SetSize(int width, int height, gin_helper::Arguments* args);
std::vector<int> GetSize() const;
std::array<int, 2U> GetSize() const;
void SetContentSize(int width, int height, gin_helper::Arguments* args);
std::vector<int> GetContentSize() const;
std::array<int, 2U> GetContentSize() const;
void SetContentBounds(const gfx::Rect& bounds, gin_helper::Arguments* args);
gfx::Rect GetContentBounds() const;
bool IsNormal() const;
gfx::Rect GetNormalBounds() const;
void SetMinimumSize(int width, int height);
std::vector<int> GetMinimumSize() const;
std::array<int, 2U> GetMinimumSize() const;
void SetMaximumSize(int width, int height);
std::vector<int> GetMaximumSize() const;
std::array<int, 2U> GetMaximumSize() const;
void SetSheetOffset(double offsetY, gin_helper::Arguments* args);
void SetResizable(bool resizable);
bool IsResizable() const;
@ -149,7 +150,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
bool IsAlwaysOnTop() const;
void Center();
void SetPosition(int x, int y, gin_helper::Arguments* args);
std::vector<int> GetPosition() const;
std::array<int, 2U> GetPosition() const;
void SetTitle(const std::string& title);
std::string GetTitle() const;
void SetAccessibleTitle(const std::string& title);