Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -2390,6 +2390,9 @@ ORIGIN: ../../../flutter/third_party/accessibility/base/win/atl_module.h + ../..
TYPE: LicenseType.bsd
FILE: ../../../flutter/third_party/accessibility/base/auto_reset.h
FILE: ../../../flutter/third_party/accessibility/base/win/atl_module.h
FILE: ../../../flutter/third_party/accessibility/base/win/display.cc
FILE: ../../../flutter/third_party/accessibility/base/win/display.h
FILE: ../../../flutter/third_party/accessibility/base/win/display_unittest.cc
FILE: ../../../flutter/third_party/accessibility/base/win/enum_variant.cc
FILE: ../../../flutter/third_party/accessibility/base/win/enum_variant.h
FILE: ../../../flutter/third_party/accessibility/base/win/enum_variant_unittest.cc
Expand Down
1 change: 1 addition & 0 deletions third_party/accessibility/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ if (enable_unittests) {
"ax/platform/ax_platform_node_win_unittest.cc",
"base/win/dispatch_stub.cc",
"base/win/dispatch_stub.h",
"base/win/display_unittest.cc",
"base/win/scoped_bstr_unittest.cc",
"base/win/scoped_safearray_unittest.cc",
"base/win/scoped_variant_unittest.cc",
Expand Down
1 change: 1 addition & 0 deletions third_party/accessibility/ax/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ source_set("ax") {
]
libs = [
"oleacc.lib",
"shcore.lib",
"uiautomationcore.lib",
]
}
Expand Down
6 changes: 3 additions & 3 deletions third_party/accessibility/ax/platform/ax_platform_node_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
#include "ax_fragment_root_win.h"
#include "ax_platform_node_delegate.h"
#include "ax_platform_node_delegate_utils_win.h"
#include "shellscalingapi.h"
#include "uia_registrar_win.h"

#include "base/logging.h"
#include "base/win/atl_module.h"
#include "base/win/display.h"
#include "gfx/geometry/rect_conversions.h"

// From ax.constants.mojom
Expand Down Expand Up @@ -476,9 +478,7 @@ gfx::Vector2d AXPlatformNodeWin::CalculateUIAScrollPoint(

const HWND hwnd = GetDelegate()->GetTargetForNativeAccessibilityEvent();
BASE_DCHECK(hwnd);
// TODO(gw280): https://github.com/flutter/flutter/issues/78798
// Support scale factors
const float scale_factor = 1.0f;
const float scale_factor = base::win::GetScaleFactorForHWND(hwnd);
const int small_change =
base::ClampRound(kSmallScrollIncrement * scale_factor);

Expand Down
2 changes: 2 additions & 0 deletions third_party/accessibility/base/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ source_set("base") {
sources += [
"win/atl.h",
"win/atl_module.h",
"win/display.cc",
"win/display.h",
"win/enum_variant.cc",
"win/enum_variant.h",
"win/scoped_bstr.cc",
Expand Down
59 changes: 59 additions & 0 deletions third_party/accessibility/base/win/display.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/win/display.h"

namespace base {
namespace win {

float GetScaleFactorForHWND(HWND hwnd) {
HMONITOR monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
DEVICE_SCALE_FACTOR scale_factor = DEVICE_SCALE_FACTOR_INVALID;
if (SUCCEEDED(GetScaleFactorForMonitor(monitor, &scale_factor))) {
return ScaleFactorToFloat(scale_factor);
}
return 1.0f;
}

float ScaleFactorToFloat(DEVICE_SCALE_FACTOR scale_factor) {
switch (scale_factor) {
case SCALE_100_PERCENT:
return 1.0f;
case SCALE_120_PERCENT:
return 1.2f;
case SCALE_125_PERCENT:
return 1.25f;
case SCALE_140_PERCENT:
return 1.4f;
case SCALE_150_PERCENT:
return 1.5f;
case SCALE_160_PERCENT:
return 1.6f;
case SCALE_175_PERCENT:
return 1.75f;
case SCALE_180_PERCENT:
return 1.8f;
case SCALE_200_PERCENT:
return 2.0f;
case SCALE_225_PERCENT:
return 2.25f;
case SCALE_250_PERCENT:
return 2.5f;
case SCALE_300_PERCENT:
return 3.0f;
case SCALE_350_PERCENT:
return 3.5f;
case SCALE_400_PERCENT:
return 4.0f;
case SCALE_450_PERCENT:
return 4.5f;
case SCALE_500_PERCENT:
return 5.0f;
default:
return 1.0f;
}
}

} // namespace win
} // namespace base
23 changes: 23 additions & 0 deletions third_party/accessibility/base/win/display.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef BASE_WIN_DISPLAY_H_
#define BASE_WIN_DISPLAY_H_

#include <windows.h>

#include <shellscalingapi.h>

#include "base/base_export.h"

namespace base {
namespace win {

float GetScaleFactorForHWND(HWND hwnd);
float ScaleFactorToFloat(DEVICE_SCALE_FACTOR scale_factor);

} // namespace win
} // namespace base

#endif // BASE_WIN_DISPLAY_H_
32 changes: 32 additions & 0 deletions third_party/accessibility/base/win/display_unittest.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/win/display.h"

#include "gtest/gtest.h"

namespace base {
namespace win {

TEST(Display, ScaleFactorToFloat) {
EXPECT_EQ(ScaleFactorToFloat(SCALE_100_PERCENT), 1.00f);
EXPECT_EQ(ScaleFactorToFloat(SCALE_120_PERCENT), 1.20f);
EXPECT_EQ(ScaleFactorToFloat(SCALE_125_PERCENT), 1.25f);
EXPECT_EQ(ScaleFactorToFloat(SCALE_140_PERCENT), 1.40f);
EXPECT_EQ(ScaleFactorToFloat(SCALE_150_PERCENT), 1.50f);
EXPECT_EQ(ScaleFactorToFloat(SCALE_160_PERCENT), 1.60f);
EXPECT_EQ(ScaleFactorToFloat(SCALE_175_PERCENT), 1.75f);
EXPECT_EQ(ScaleFactorToFloat(SCALE_180_PERCENT), 1.80f);
EXPECT_EQ(ScaleFactorToFloat(SCALE_200_PERCENT), 2.00f);
EXPECT_EQ(ScaleFactorToFloat(SCALE_225_PERCENT), 2.25f);
EXPECT_EQ(ScaleFactorToFloat(SCALE_250_PERCENT), 2.50f);
EXPECT_EQ(ScaleFactorToFloat(SCALE_350_PERCENT), 3.50f);
EXPECT_EQ(ScaleFactorToFloat(SCALE_400_PERCENT), 4.00f);
EXPECT_EQ(ScaleFactorToFloat(SCALE_450_PERCENT), 4.50f);
EXPECT_EQ(ScaleFactorToFloat(SCALE_500_PERCENT), 5.00f);
EXPECT_EQ(ScaleFactorToFloat(DEVICE_SCALE_FACTOR_INVALID), 1.0f);
}

} // namespace win
} // namespace base