Commit cef0b457 authored by Daichi Hirono's avatar Daichi Hirono Committed by Commit Bot

Assign accessibility ID from client to window

BUG=b:146591913
TEST=ShellSurfaceTest.SetClientAccessibilityId

Change-Id: I96c5086a9162114432e83c01ac0a36b947ffb180
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1981963Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Daichi Hirono <hirono@chromium.org>
Auto-Submit: Daichi Hirono <hirono@chromium.org>
Cr-Commit-Position: refs/heads/master@{#729626}
parent d99281fc
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "base/trace_event/traced_value.h" #include "base/trace_event/traced_value.h"
#include "components/exo/shell_surface_util.h"
#include "components/exo/surface.h" #include "components/exo/surface.h"
#include "components/exo/wm_helper.h" #include "components/exo/wm_helper.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
...@@ -578,6 +579,19 @@ void ClientControlledShellSurface::SetOrientationLock( ...@@ -578,6 +579,19 @@ void ClientControlledShellSurface::SetOrientationLock(
widget_->GetNativeWindow(), orientation_lock); widget_->GetNativeWindow(), orientation_lock);
} }
void ClientControlledShellSurface::SetClientAccessibilityId(
int32_t accessibility_id) {
if (accessibility_id >= 0)
client_accessibility_id_ = accessibility_id;
else
client_accessibility_id_.reset();
if (widget_ && widget_->GetNativeWindow()) {
SetShellClientAccessibilityId(widget_->GetNativeWindow(),
client_accessibility_id_);
}
}
void ClientControlledShellSurface::OnBoundsChangeEvent( void ClientControlledShellSurface::OnBoundsChangeEvent(
ash::WindowStateType current_state, ash::WindowStateType current_state,
ash::WindowStateType requested_state, ash::WindowStateType requested_state,
...@@ -938,6 +952,9 @@ void ClientControlledShellSurface::InitializeWindowState( ...@@ -938,6 +952,9 @@ void ClientControlledShellSurface::InitializeWindowState(
accelerator_target_->RegisterAccelerator( accelerator_target_->RegisterAccelerator(
ui::Accelerator(entry.keycode, entry.modifiers), entry.action); ui::Accelerator(entry.keycode, entry.modifiers), entry.action);
} }
auto* window = widget_->GetNativeWindow();
SetShellClientAccessibilityId(window, client_accessibility_id_);
} }
float ClientControlledShellSurface::GetScale() const { float ClientControlledShellSurface::GetScale() const {
......
...@@ -209,6 +209,10 @@ class ClientControlledShellSurface : public ShellSurfaceBase, ...@@ -209,6 +209,10 @@ class ClientControlledShellSurface : public ShellSurfaceBase,
// //ash/display/screen_orientation_controller.h. // //ash/display/screen_orientation_controller.h.
void SetOrientationLock(ash::OrientationLockType orientation_lock); void SetOrientationLock(ash::OrientationLockType orientation_lock);
// Set the accessibility ID provided by client for the surface. If
// |accessibility_id| is negative value, it will unset the ID.
void SetClientAccessibilityId(int32_t accessibility_id);
// Overridden from SurfaceDelegate: // Overridden from SurfaceDelegate:
bool IsInputEnabled(Surface* surface) const override; bool IsInputEnabled(Surface* surface) const override;
void OnSetFrame(SurfaceFrameType type) override; void OnSetFrame(SurfaceFrameType type) override;
...@@ -357,6 +361,9 @@ class ClientControlledShellSurface : public ShellSurfaceBase, ...@@ -357,6 +361,9 @@ class ClientControlledShellSurface : public ShellSurfaceBase,
// Client controlled specific accelerator target. // Client controlled specific accelerator target.
std::unique_ptr<ClientControlledAcceleratorTarget> accelerator_target_; std::unique_ptr<ClientControlledAcceleratorTarget> accelerator_target_;
// Accessibility ID provided by client.
base::Optional<int32_t> client_accessibility_id_;
DISALLOW_COPY_AND_ASSIGN(ClientControlledShellSurface); DISALLOW_COPY_AND_ASSIGN(ClientControlledShellSurface);
}; };
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "components/exo/buffer.h" #include "components/exo/buffer.h"
#include "components/exo/display.h" #include "components/exo/display.h"
#include "components/exo/pointer.h" #include "components/exo/pointer.h"
#include "components/exo/shell_surface_util.h"
#include "components/exo/sub_surface.h" #include "components/exo/sub_surface.h"
#include "components/exo/surface.h" #include "components/exo/surface.h"
#include "components/exo/test/exo_test_base.h" #include "components/exo/test/exo_test_base.h"
...@@ -1848,6 +1849,28 @@ TEST_F(ClientControlledShellSurfaceTest, SetOrientationLock) { ...@@ -1848,6 +1849,28 @@ TEST_F(ClientControlledShellSurfaceTest, SetOrientationLock) {
EnableTabletMode(false); EnableTabletMode(false);
} }
TEST_F(ClientControlledShellSurfaceTest, SetClientAccessibilityId) {
gfx::Size buffer_size(64, 64);
std::unique_ptr<Buffer> buffer(
new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
std::unique_ptr<Surface> surface(new Surface);
auto shell_surface =
exo_test_helper()->CreateClientControlledShellSurface(surface.get());
EXPECT_FALSE(shell_surface->GetWidget());
shell_surface->SetClientAccessibilityId(0);
surface->Attach(buffer.get());
surface->Commit();
aura::Window* window = shell_surface->GetWidget()->GetNativeWindow();
EXPECT_EQ(0, *GetShellClientAccessibilityId(window));
shell_surface->SetClientAccessibilityId(1);
EXPECT_EQ(1, *GetShellClientAccessibilityId(window));
shell_surface->SetClientAccessibilityId(-1);
EXPECT_FALSE(GetShellClientAccessibilityId(window));
}
// Tests adjust bounds locally should also request remote client bounds update. // Tests adjust bounds locally should also request remote client bounds update.
TEST_F(ClientControlledShellSurfaceTest, AdjustBoundsLocally) { TEST_F(ClientControlledShellSurfaceTest, AdjustBoundsLocally) {
UpdateDisplay("800x600"); UpdateDisplay("800x600");
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <memory> #include <memory>
#include "ash/public/cpp/app_types.h" #include "ash/public/cpp/app_types.h"
#include "base/strings/string_number_conversions.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "components/exo/permission.h" #include "components/exo/permission.h"
#include "components/exo/shell_surface_base.h" #include "components/exo/shell_surface_base.h"
...@@ -33,6 +34,9 @@ DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(std::string, kApplicationIdKey, nullptr) ...@@ -33,6 +34,9 @@ DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(std::string, kApplicationIdKey, nullptr)
// Startup Id set by the client. // Startup Id set by the client.
DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(std::string, kStartupIdKey, nullptr) DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(std::string, kStartupIdKey, nullptr)
// Accessibility Id set by the client.
DEFINE_UI_CLASS_PROPERTY_KEY(int32_t, kClientAccessibilityIdKey, -1)
// Permission object allowing this window to activate itself. // Permission object allowing this window to activate itself.
DEFINE_UI_CLASS_PROPERTY_KEY(exo::Permission*, kPermissionKey, nullptr) DEFINE_UI_CLASS_PROPERTY_KEY(exo::Permission*, kPermissionKey, nullptr)
...@@ -71,6 +75,26 @@ const std::string* GetShellStartupId(aura::Window* window) { ...@@ -71,6 +75,26 @@ const std::string* GetShellStartupId(aura::Window* window) {
return window->GetProperty(kStartupIdKey); return window->GetProperty(kStartupIdKey);
} }
void SetShellClientAccessibilityId(aura::Window* window,
const base::Optional<int32_t>& id) {
TRACE_EVENT1("exo", "SetClientAccessibilityId", "id",
id ? base::NumberToString(*id) : "null");
if (id)
window->SetProperty(kClientAccessibilityIdKey, *id);
else
window->ClearProperty(kClientAccessibilityIdKey);
}
const base::Optional<int32_t> GetShellClientAccessibilityId(
aura::Window* window) {
auto id = window->GetProperty(kClientAccessibilityIdKey);
if (id < 0)
return base::nullopt;
else
return id;
}
void SetShellMainSurface(aura::Window* window, Surface* surface) { void SetShellMainSurface(aura::Window* window, Surface* surface) {
window->SetProperty(kMainSurfaceKey, surface); window->SetProperty(kMainSurfaceKey, surface);
} }
......
...@@ -43,6 +43,13 @@ void SetShellStartupId(aura::Window* window, ...@@ -43,6 +43,13 @@ void SetShellStartupId(aura::Window* window,
const base::Optional<std::string>& id); const base::Optional<std::string>& id);
const std::string* GetShellStartupId(aura::Window* window); const std::string* GetShellStartupId(aura::Window* window);
// Sets the client accessibility ID for the window. The accessibility ID
// identifies the accessibility tree provided by client.
void SetShellClientAccessibilityId(aura::Window* window,
const base::Optional<int32_t>& id);
const base::Optional<int32_t> GetShellClientAccessibilityId(
aura::Window* window);
// Sets the main surface for the window. // Sets the main surface for the window.
void SetShellMainSurface(aura::Window* window, Surface* surface); void SetShellMainSurface(aura::Window* window, Surface* surface);
......
...@@ -547,7 +547,8 @@ void remote_surface_unblock_ime(wl_client* client, wl_resource* resource) { ...@@ -547,7 +547,8 @@ void remote_surface_unblock_ime(wl_client* client, wl_resource* resource) {
void remote_surface_set_accessibility_id(wl_client* client, void remote_surface_set_accessibility_id(wl_client* client,
wl_resource* resource, wl_resource* resource,
int32_t accessibility_id) { int32_t accessibility_id) {
NOTIMPLEMENTED(); GetUserDataAs<ClientControlledShellSurface>(resource)
->SetClientAccessibilityId(accessibility_id);
} }
void remote_surface_set_pip_original_window(wl_client* client, void remote_surface_set_pip_original_window(wl_client* client,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment