Skip to content

Commit 0751180

Browse files
committed
Improve comments and code style consistency
1 parent 12c4f47 commit 0751180

File tree

3 files changed

+27
-25
lines changed

3 files changed

+27
-25
lines changed

engine/src/flutter/shell/platform/windows/flutter_host_window.cc

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,13 @@ std::string GetLastErrorAsString() {
131131
}
132132

133133
// Calculates the required window size, in physical coordinates, to
134-
// accommodate the given |client_size|, in logical coordinates, constrained to
135-
// |min_size| and |max_size|, for a window with the specified |window_style| and
136-
// |extended_window_style|. The result accounts for window borders, non-client
137-
// areas, and the drop-shadow area. On error, return std::nullopt and log the
138-
// error.
134+
// accommodate the given |client_size|, in logical coordinates, constrained by
135+
// optional |min_size| and |max_size|, for a window with the specified
136+
// |window_style| and |extended_window_style|. If |owner_hwnd| is not null, the
137+
// DPI of the display with the largest area of intersection with |owner_hwnd| is
138+
// used for the calculation; otherwise, the primary display's DPI is used. The
139+
// resulting size includes window borders, non-client areas, and drop shadows.
140+
// On error, returns std::nullopt and logs an error message.
139141
std::optional<flutter::Size> GetWindowSizeForClientSize(
140142
flutter::Size const& client_size,
141143
std::optional<flutter::Size> min_size,
@@ -210,7 +212,7 @@ bool IsClassRegistered(LPCWSTR class_name) {
210212
0;
211213
}
212214

213-
// Convert std::string to std::wstring
215+
// Convert std::string to std::wstring.
214216
std::wstring StringToWstring(std::string const& str) {
215217
if (str.empty()) {
216218
return {};
@@ -280,7 +282,7 @@ FlutterHostWindow::FlutterHostWindow(FlutterHostWindowController* controller,
280282
FML_UNREACHABLE();
281283
}
282284

283-
// Validate size constraints
285+
// Validate size constraints.
284286
min_size_ = settings.min_size;
285287
max_size_ = settings.max_size;
286288
if (min_size_ && max_size_) {
@@ -293,8 +295,8 @@ FlutterHostWindow::FlutterHostWindow(FlutterHostWindowController* controller,
293295

294296
// Calculate the screen space window rectangle for the new window.
295297
// Default positioning values (CW_USEDEFAULT) are used
296-
// if the window has no owner or positioner.
297-
Rect initial_window_rect = [&]() -> Rect {
298+
// if the window has no owner.
299+
Rect const initial_window_rect = [&]() -> Rect {
298300
std::optional<Size> const window_size = GetWindowSizeForClientSize(
299301
settings.size, min_size_, max_size_, window_style,
300302
extended_window_style, nullptr);
@@ -556,7 +558,7 @@ LRESULT FlutterHostWindow::HandleMessage(HWND hwnd,
556558

557559
case WM_SIZE: {
558560
if (child_content_ != nullptr) {
559-
// Resize and reposition the child content window
561+
// Resize and reposition the child content window.
560562
RECT client_rect;
561563
GetClientRect(hwnd, &client_rect);
562564
MoveWindow(child_content_, client_rect.left, client_rect.top,

engine/src/flutter/shell/platform/windows/flutter_host_window_controller.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@ std::optional<WindowMetadata> FlutterHostWindowController::CreateHostWindow(
5151
WindowState const state = window->GetState();
5252
windows_[view_id] = std::move(window);
5353

54-
WindowMetadata result = {.view_id = view_id,
55-
.archetype = settings.archetype,
56-
.size = GetWindowSize(view_id),
57-
.parent_id = std::nullopt,
58-
.state = state};
54+
WindowMetadata const result = {.view_id = view_id,
55+
.archetype = settings.archetype,
56+
.size = GetWindowSize(view_id),
57+
.parent_id = std::nullopt,
58+
.state = state};
5959

6060
return result;
6161
}
6262

6363
bool FlutterHostWindowController::DestroyHostWindow(FlutterViewId view_id) {
64-
if (auto it = windows_.find(view_id); it != windows_.end()) {
64+
if (auto const it = windows_.find(view_id); it != windows_.end()) {
6565
FlutterHostWindow* const window = it->second.get();
6666
HWND const window_handle = window->GetWindowHandle();
6767

@@ -75,7 +75,7 @@ bool FlutterHostWindowController::DestroyHostWindow(FlutterViewId view_id) {
7575

7676
FlutterHostWindow* FlutterHostWindowController::GetHostWindow(
7777
FlutterViewId view_id) const {
78-
if (auto it = windows_.find(view_id); it != windows_.end()) {
78+
if (auto const it = windows_.find(view_id); it != windows_.end()) {
7979
return it->second.get();
8080
}
8181
return nullptr;
@@ -146,7 +146,7 @@ void FlutterHostWindowController::DestroyAllWindows() {
146146
// Destroy windows in reverse order of creation.
147147
for (auto it = std::prev(windows_.end());
148148
it != std::prev(windows_.begin());) {
149-
auto current = it--;
149+
auto const current = it--;
150150
auto const& [view_id, window] = *current;
151151
if (window->GetWindowHandle()) {
152152
DestroyHostWindow(view_id);

engine/src/flutter/shell/platform/windows/windowing_handler.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ std::optional<std::vector<T>> GetListOfValuesForKeyOrSendError(
103103
return decoded_values;
104104
}
105105

106-
// If the value exists but is not a list
106+
// If the value exists but is not a list.
107107
result.Error(kInvalidValueError,
108108
"Value for key '" + key + "' key must be an array.");
109109
return std::nullopt;
@@ -152,7 +152,7 @@ void WindowingHandler::HandleCreateWindow(WindowArchetype archetype,
152152
return;
153153
}
154154

155-
// Helper lambda to check and report invalid window size
155+
// Helper lambda to check and report invalid window size.
156156
auto const has_valid_window_size =
157157
[&result](Size size, std::string_view key_name) -> bool {
158158
if (size.width() <= 0 || size.height() <= 0) {
@@ -167,7 +167,7 @@ void WindowingHandler::HandleCreateWindow(WindowArchetype archetype,
167167

168168
WindowCreationSettings settings;
169169

170-
// Get value for the 'size' key (non-nullable)
170+
// Get value for the 'size' key (non-nullable).
171171
auto const size_list =
172172
GetListOfValuesForKeyOrSendError<double, 2>(kSizeKey, map, result);
173173
if (!size_list) {
@@ -181,27 +181,27 @@ void WindowingHandler::HandleCreateWindow(WindowArchetype archetype,
181181
}
182182

183183
if (archetype == WindowArchetype::kRegular) {
184-
// Get value for the 'minSize' key (nullable)
184+
// Get value for the 'minSize' key (nullable).
185185
if (auto const list = GetListOfValuesForKeyOrSendError<double, 2>(
186186
kMinSizeKey, map, result)) {
187187
settings.min_size = {list->at(0), list->at(1)};
188188
if (!has_valid_window_size(*settings.min_size, kMinSizeKey)) {
189189
return;
190190
}
191191
}
192-
// Get value for the 'maxSize' key (nullable)
192+
// Get value for the 'maxSize' key (nullable).
193193
if (auto const list = GetListOfValuesForKeyOrSendError<double, 2>(
194194
kMaxSizeKey, map, result)) {
195195
settings.max_size = {list->at(0), list->at(1)};
196196
if (!has_valid_window_size(*settings.max_size, kMaxSizeKey)) {
197197
return;
198198
}
199199
}
200-
// Get value for the 'title' key (nullable)
200+
// Get value for the 'title' key (nullable).
201201
settings.title =
202202
GetSingleValueForKeyOrSendError<std::string>(kTitleKey, map, result);
203203

204-
// Get value for the 'state' key (nullable)
204+
// Get value for the 'state' key (nullable).
205205
if (std::optional<std::string> state_string =
206206
GetSingleValueForKeyOrSendError<std::string>(kStateKey, map,
207207
result)) {

0 commit comments

Comments
 (0)