-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path2a70ef0e63eb0cb3c9e1abae955b31ad8028cdf6.diff
410 lines (380 loc) · 17.1 KB
/
2a70ef0e63eb0cb3c9e1abae955b31ad8028cdf6.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
diff --git a/ui/accessibility/platform/ax_platform_node_win.cc b/ui/accessibility/platform/ax_platform_node_win.cc
index 46f557f488090..5250285054abd 100644
--- a/ui/accessibility/platform/ax_platform_node_win.cc
+++ b/ui/accessibility/platform/ax_platform_node_win.cc
@@ -2573,7 +2573,7 @@ IFACEMETHODIMP AXPlatformNodeWin::get_Target(
// If there is no reverse relation target, IAnnotationProvider
// should not be exposed in the first place.
- DCHECK_GT(reverse_relations.size(), 0u);
+ DCHECK(reverse_relations.size() > 0);
AXPlatformNodeWin* target_node;
auto iter = reverse_relations.begin();
target_node = static_cast<AXPlatformNodeWin*>(*iter);
@@ -5441,26 +5441,42 @@ HRESULT AXPlatformNodeWin::GetPropertyValueImpl(PROPERTYID property_id,
// if the internal role cannot be accurately described by its UIA Control
// Type or aria role, we should instead provide our own localized
// description.
- if (GetUIARoleProperties().localization_strategy ==
- UIALocalizationStrategy::kSupply) {
- // According to the HTML-AAM, UIA expects <output> to have a
- // Localized Control Type of "output" whereas the Core-AAM states
- // the Localized Control Type of the ARIA status role should be
- // "status".
- const std::string& html_tag =
- GetStringAttribute(ax::mojom::StringAttribute::kHtmlTag);
- std::u16string localized_control_type =
- html_tag == "output" ? l10n_util::GetStringUTF16(IDS_AX_ROLE_OUTPUT)
- : GetRoleDescription();
-
- if (!localized_control_type.empty()) {
- result->vt = VT_BSTR;
- result->bstrVal =
- SysAllocString(base::as_wcstr(localized_control_type));
- }
- } // If a role description has not been provided, leave as VT_EMPTY.
- break;
- }
+ UIALocalizationStrategy localization_strategy =
+ GetUIARoleProperties().localization_strategy;
+ switch (localization_strategy) {
+ case UIALocalizationStrategy::kDeferToControlType:
+ break;
+ case UIALocalizationStrategy::kDeferToAriaRole:
+ if (base::win::GetVersion() >= base::win::Version::WIN8) {
+ // On Windows 8 onward, UIA can provide localization from the
+ // aria role.
+ break;
+ }
+ // On versions before 8, we should not rely on UIA to generate
+ // localization from the aria role, instead we should supply our own
+ // localization.
+ ABSL_FALLTHROUGH_INTENDED;
+ case UIALocalizationStrategy::kSupply:
+ // According to the HTML-AAM, UIA expects <output> to have a
+ // Localized Control Type of "output" whereas the Core-AAM states
+ // the Localized Control Type of the ARIA status role should be
+ // "status".
+ const std::string& html_tag =
+ GetStringAttribute(ax::mojom::StringAttribute::kHtmlTag);
+ std::u16string localized_control_type =
+ html_tag == "output"
+ ? l10n_util::GetStringUTF16(IDS_AX_ROLE_OUTPUT)
+ : GetRoleDescription();
+
+ if (!localized_control_type.empty()) {
+ result->vt = VT_BSTR;
+ result->bstrVal =
+ SysAllocString(base::as_wcstr(localized_control_type));
+ }
+ // If a role description has not been provided, leave as VT_EMPTY.
+ }
+ } break;
+
case UIA_NamePropertyId:
if (IsNameExposed()) {
result->vt = VT_BSTR;
diff --git a/ui/accessibility/platform/inspect/ax_inspect_test_helper.cc b/ui/accessibility/platform/inspect/ax_inspect_test_helper.cc
index c212e27b19309..f657ef40c7d2e 100644
--- a/ui/accessibility/platform/inspect/ax_inspect_test_helper.cc
+++ b/ui/accessibility/platform/inspect/ax_inspect_test_helper.cc
@@ -4,9 +4,6 @@
#include "ui/accessibility/platform/inspect/ax_inspect_test_helper.h"
-#include <string>
-#include <vector>
-
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/logging.h"
@@ -21,6 +18,9 @@
#include "ui/accessibility/platform/inspect/ax_inspect_scenario.h"
#include "ui/base/buildflags.h"
+#if BUILDFLAG(IS_WIN)
+#include "base/win/windows_version.h"
+#endif
#if BUILDFLAG(USE_ATK)
extern "C" {
#include <atk/atk.h>
@@ -353,6 +353,15 @@ FilePath::StringType AXInspectTestHelper::GetExpectedFileSuffix(
FilePath::StringType AXInspectTestHelper::GetVersionSpecificExpectedFileSuffix(
const base::FilePath::StringType& expectations_qualifier) const {
+#if BUILDFLAG(IS_WIN)
+ if (expectation_type_ == "uia" &&
+ base::win::GetVersion() == base::win::Version::WIN7) {
+ FilePath::StringType suffix;
+ if (!expectations_qualifier.empty())
+ suffix = FILE_PATH_LITERAL("-") + expectations_qualifier;
+ return suffix + FILE_PATH_LITERAL("-expected-uia-win7.txt");
+ }
+#endif
#if BUILDFLAG(USE_ATK)
if (expectation_type_ == "linux") {
FilePath::StringType version_name;
diff --git a/ui/aura/native_window_occlusion_tracker_unittest.cc b/ui/aura/native_window_occlusion_tracker_unittest.cc
index ed19896be1b22..e27059868a4c6 100644
--- a/ui/aura/native_window_occlusion_tracker_unittest.cc
+++ b/ui/aura/native_window_occlusion_tracker_unittest.cc
@@ -4,16 +4,18 @@
#include "ui/aura/native_window_occlusion_tracker_win.h"
-#include <dwmapi.h>
#include <winuser.h>
#include "base/win/scoped_gdi_object.h"
#include "base/win/scoped_hdc.h"
+#include "base/win/windows_version.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/test/aura_test_base.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/win/window_impl.h"
+#include "dwmapi.h"
+
namespace aura {
// Test wrapper around native window HWND.
@@ -229,6 +231,9 @@ TEST_F(NativeWindowOcclusionTrackerTest, PopupWindow) {
}
TEST_F(NativeWindowOcclusionTrackerTest, CloakedWindow) {
+ // Cloaking is only supported in Windows 8 and above.
+ if (base::win::GetVersion() < base::win::Version::WIN8)
+ return;
HWND hwnd = CreateNativeWindow(/*style=*/0, /*ex_style=*/0);
gfx::Rect win_rect;
BOOL cloak = TRUE;
diff --git a/ui/aura/native_window_occlusion_tracker_win.cc b/ui/aura/native_window_occlusion_tracker_win.cc
index 1a0b1ab293042..e47fa56624119 100644
--- a/ui/aura/native_window_occlusion_tracker_win.cc
+++ b/ui/aura/native_window_occlusion_tracker_win.cc
@@ -22,6 +22,7 @@
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/win/scoped_gdi_object.h"
+#include "base/win/windows_version.h"
#include "ui/aura/window_occlusion_tracker.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/ui_base_features.h"
@@ -427,8 +428,10 @@ NativeWindowOcclusionTrackerWin::WindowOcclusionCalculator::
calculate_occluded_region_(base::FeatureList::IsEnabled(
features::kApplyNativeOccludedRegionToWindowTracker)),
update_occlusion_state_callback_(update_occlusion_state_callback) {
- ::CoCreateInstance(__uuidof(VirtualDesktopManager), nullptr, CLSCTX_ALL,
- IID_PPV_ARGS(&virtual_desktop_manager_));
+ if (base::win::GetVersion() >= base::win::Version::WIN10) {
+ ::CoCreateInstance(__uuidof(VirtualDesktopManager), nullptr, CLSCTX_ALL,
+ IID_PPV_ARGS(&virtual_desktop_manager_));
+ }
DETACH_FROM_SEQUENCE(sequence_checker_);
}
diff --git a/ui/aura/native_window_occlusion_tracker_win_interactive_test.cc b/ui/aura/native_window_occlusion_tracker_win_interactive_test.cc
index b91cd0c3f9f40..2acc9976de870 100644
--- a/ui/aura/native_window_occlusion_tracker_win_interactive_test.cc
+++ b/ui/aura/native_window_occlusion_tracker_win_interactive_test.cc
@@ -16,6 +16,7 @@
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/win/scoped_gdi_object.h"
+#include "base/win/windows_version.h"
#include "mojo/core/embedder/embedder.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/env.h"
@@ -548,6 +549,13 @@ TEST_F(NativeWindowOcclusionTrackerTest,
// is marked as occluded. TODO(crbug.com/40833493): Fix flakiness.
TEST_F(NativeWindowOcclusionTrackerTest,
DISABLED_MaximizedOccludedByFullscreenWindow) {
+ // Win7 has non rectangular windows and odd padding; this breaks fullscreen
+ // window occlusion of maximized windows, which makes this test fail on Win7.
+ // Win7 support is going away soon and shouldn't get in the way of this test
+ // coverage.
+ if (base::win::GetVersion() <= base::win::Version::WIN7)
+ return;
+
// Create an aura window that is maximized.
base::RunLoop run_loop1;
MockWindowTreeHostObserver observer(run_loop1.QuitClosure());
diff --git a/ui/base/ime/init/input_method_factory.cc b/ui/base/ime/init/input_method_factory.cc
index 5d4a41a4d64c2..31ad0c6590ab7 100644
--- a/ui/base/ime/init/input_method_factory.cc
+++ b/ui/base/ime/init/input_method_factory.cc
@@ -13,6 +13,7 @@
#include "ui/gfx/switches.h"
#if BUILDFLAG(IS_WIN)
+#include "base/win/windows_version.h"
#include "ui/base/ime/win/input_method_win_imm32.h"
#include "ui/base/ime/win/input_method_win_tsf.h"
#elif BUILDFLAG(IS_APPLE)
@@ -54,7 +55,8 @@ std::unique_ptr<InputMethod> CreateInputMethod(
return base::WrapUnique(new MockInputMethod(ime_key_event_dispatcher));
#if BUILDFLAG(IS_WIN)
- if (base::FeatureList::IsEnabled(features::kTSFImeSupport)) {
+ if (base::FeatureList::IsEnabled(features::kTSFImeSupport) &&
+ base::win::GetVersion() > base::win::Version::WIN7) {
return std::make_unique<InputMethodWinTSF>(ime_key_event_dispatcher,
widget);
}
diff --git a/ui/base/ime/win/input_method_win_base.cc b/ui/base/ime/win/input_method_win_base.cc
index d838ade885c18..73fa6928a2378 100644
--- a/ui/base/ime/win/input_method_win_base.cc
+++ b/ui/base/ime/win/input_method_win_base.cc
@@ -41,10 +41,11 @@ std::unique_ptr<VirtualKeyboardController> CreateKeyboardController(
if (base::win::GetVersion() >= base::win::Version::WIN10_RS4) {
return std::make_unique<OnScreenKeyboardDisplayManagerInputPane>(
attached_window_handle);
- } else {
+ } else if (base::win::GetVersion() >= base::win::Version::WIN8) {
return std::make_unique<OnScreenKeyboardDisplayManagerTabTip>(
attached_window_handle);
}
+ return nullptr;
}
// Checks if a given primary language ID is a RTL language.
diff --git a/ui/base/ime/win/on_screen_keyboard_display_manager_tab_tip.cc b/ui/base/ime/win/on_screen_keyboard_display_manager_tab_tip.cc
index b555d53332335..fb7dd1270f7c9 100644
--- a/ui/base/ime/win/on_screen_keyboard_display_manager_tab_tip.cc
+++ b/ui/base/ime/win/on_screen_keyboard_display_manager_tab_tip.cc
@@ -20,6 +20,7 @@
#include "base/win/registry.h"
#include "base/win/scoped_co_mem.h"
#include "base/win/win_util.h"
+#include "base/win/windows_version.h"
#include "ui/base/ime/virtual_keyboard_controller_observer.h"
#include "ui/base/win/hidden_window.h"
#include "ui/display/win/screen_win.h"
@@ -255,7 +256,9 @@ void OnScreenKeyboardDetector::HandleKeyboardHidden() {
// OnScreenKeyboardDisplayManagerTabTip member definitions.
OnScreenKeyboardDisplayManagerTabTip::OnScreenKeyboardDisplayManagerTabTip(
HWND hwnd)
- : hwnd_(hwnd) {}
+ : hwnd_(hwnd) {
+ DCHECK_GE(base::win::GetVersion(), base::win::Version::WIN8);
+}
OnScreenKeyboardDisplayManagerTabTip::~OnScreenKeyboardDisplayManagerTabTip() {}
diff --git a/ui/base/ime/win/on_screen_keyboard_display_manager_unittest.cc b/ui/base/ime/win/on_screen_keyboard_display_manager_unittest.cc
index 97fc29307d550..2af05b9961e5a 100644
--- a/ui/base/ime/win/on_screen_keyboard_display_manager_unittest.cc
+++ b/ui/base/ime/win/on_screen_keyboard_display_manager_unittest.cc
@@ -141,6 +141,10 @@ class OnScreenKeyboardTest : public ::testing::Test {
// This test validates the on screen keyboard path (tabtip.exe) which is read
// from the registry.
TEST_F(OnScreenKeyboardTest, OSKPath) {
+ // The on screen keyboard is only available on Windows 8+.
+ if (base::win::GetVersion() < base::win::Version::WIN8)
+ return;
+
std::unique_ptr<OnScreenKeyboardDisplayManagerTabTip>
keyboard_display_manager(CreateTabTip());
EXPECT_NE(nullptr, keyboard_display_manager);
diff --git a/ui/base/ime/win/tsf_input_scope.cc b/ui/base/ime/win/tsf_input_scope.cc
index e4da2a642cff4..b671ac139a4d3 100644
--- a/ui/base/ime/win/tsf_input_scope.cc
+++ b/ui/base/ime/win/tsf_input_scope.cc
@@ -12,8 +12,10 @@
#include "base/containers/contains.h"
#include "base/task/current_thread.h"
#include "base/trace_event/trace_event.h"
+#include "base/win/windows_version.h"
-namespace ui::tsf_inputscope {
+namespace ui {
+namespace tsf_inputscope {
namespace {
void AppendNonTrivialInputScope(std::vector<InputScope>* input_scopes,
@@ -189,8 +191,9 @@ ITfInputScope* CreateInputScope(TextInputType text_input_type,
bool should_do_learning) {
std::vector<InputScope> input_scopes;
// Should set input scope to IS_PRIVATE if we are in "incognito" or "guest"
- // mode.
- if (!should_do_learning) {
+ // mode. Note that the IS_PRIVATE input scope is only support from WIN10.
+ if (!should_do_learning &&
+ (base::win::GetVersion() >= base::win::Version::WIN10)) {
input_scopes.push_back(IS_PRIVATE);
} else {
input_scopes = GetInputScopes(text_input_type, text_input_mode);
@@ -237,4 +240,5 @@ void SetInputScopeForTsfUnawareWindow(HWND window_handle,
NULL, 0, NULL, NULL);
}
-} // namespace ui::tsf_inputscope
+} // namespace tsf_inputscope
+} // namespace ui
diff --git a/ui/base/ime/win/tsf_input_scope_unittest.cc b/ui/base/ime/win/tsf_input_scope_unittest.cc
index e222981ea01a4..57c891c45d456 100644
--- a/ui/base/ime/win/tsf_input_scope_unittest.cc
+++ b/ui/base/ime/win/tsf_input_scope_unittest.cc
@@ -8,6 +8,7 @@
#include <stddef.h>
#include <wrl/client.h>
+#include "base/win/windows_version.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace ui {
@@ -133,6 +134,8 @@ const CreateInputScopesTestCase kCreateInputScopesTestCases[] = {
{TEXT_INPUT_TYPE_NUMBER, TEXT_INPUT_MODE_NUMERIC, false, 1, {IS_PRIVATE}},
};
TEST_P(TSFCreateInputScopeTest, CreateInputScopes) {
+ if (base::win::GetVersion() < base::win::Version::WIN10)
+ return;
const CreateInputScopesTestCase& test_case = GetParam();
Microsoft::WRL::ComPtr<ITfInputScope> input_scope =
tsf_inputscope::CreateInputScope(test_case.input_type,
diff --git a/ui/base/pointer/touch_ui_controller.cc b/ui/base/pointer/touch_ui_controller.cc
index 9d2f88df875ab..d3e582ed3c27e 100644
--- a/ui/base/pointer/touch_ui_controller.cc
+++ b/ui/base/pointer/touch_ui_controller.cc
@@ -18,6 +18,7 @@
#if BUILDFLAG(IS_WIN)
#include "base/win/win_util.h"
+#include "base/win/windows_version.h"
#include "ui/gfx/win/singleton_hwnd.h"
#include "ui/gfx/win/singleton_hwnd_observer.h"
#endif
@@ -78,6 +79,7 @@ TouchUiController* TouchUiController::Get() {
TouchUiController::TouchUiController(TouchUiState touch_ui_state)
: touch_ui_state_(touch_ui_state) {
- if (base::CurrentUIThread::IsSet()) {
+ if (base::CurrentUIThread::IsSet() &&
+ base::win::GetVersion() >= base::win::Version::WIN10) {
#if BUILDFLAG(USE_BLINK)
// Pass the work to a separate task to avoid affecting browser startup time.
base::SequencedTaskRunner::GetCurrentDefault()->PostTask(
diff --git a/ui/base/ui_base_features.cc b/ui/base/ui_base_features.cc
index f6f2a117b4975..de4867665419d 100644
--- a/ui/base/ui_base_features.cc
+++ b/ui/base/ui_base_features.cc
@@ -11,6 +11,10 @@
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
+#if BUILDFLAG(IS_WIN)
+#include "base/win/windows_version.h"
+#endif
+
#if BUILDFLAG(IS_ANDROID)
#include "base/android/build_info.h"
#endif
@@ -255,7 +259,8 @@ BASE_FEATURE(kPointerEventsForTouch,
BASE_FEATURE(kTSFImeSupport, "TSFImeSupport", base::FEATURE_ENABLED_BY_DEFAULT);
bool IsUsingWMPointerForTouch() {
- return base::FeatureList::IsEnabled(kPointerEventsForTouch);
+ return base::win::GetVersion() >= base::win::Version::WIN8 &&
+ base::FeatureList::IsEnabled(kPointerEventsForTouch);
}
#endif // BUILDFLAG(IS_WIN)
diff --git a/ui/base/win/lock_state.cc b/ui/base/win/lock_state.cc
index e2136ed96ee92..791720d4a9b79 100644
--- a/ui/base/win/lock_state.cc
+++ b/ui/base/win/lock_state.cc
@@ -9,6 +9,7 @@
#include "base/functional/bind.h"
#include "base/no_destructor.h"
+#include "base/win/windows_version.h"
#include "ui/base/win/session_change_observer.h"
namespace ui {
@@ -24,8 +25,13 @@ bool IsSessionLocked() {
WTSSessionInfoEx, &buffer, &buffer_length) &&
buffer_length >= sizeof(WTSINFOEXW)) {
auto* info = reinterpret_cast<WTSINFOEXW*>(buffer);
- is_locked =
- info->Data.WTSInfoExLevel1.SessionFlags == WTS_SESSIONSTATE_LOCK;
+ auto session_flags = info->Data.WTSInfoExLevel1.SessionFlags;
+ // For Windows 7 SessionFlags has inverted logic:
+ // https://msdn.microsoft.com/en-us/library/windows/desktop/ee621019.
+ if (base::win::GetVersion() == base::win::Version::WIN7)
+ is_locked = session_flags == WTS_SESSIONSTATE_UNLOCK;
+ else
+ is_locked = session_flags == WTS_SESSIONSTATE_LOCK;
}
if (buffer)
::WTSFreeMemory(buffer);