chromium/third_party/blink/public/mojom/render_accessibility.mojom

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module blink.mojom;

import "ui/accessibility/ax_enums.mojom";
import "ui/accessibility/mojom/ax_action_data.mojom";
import "ui/accessibility/mojom/ax_event.mojom";
import "ui/accessibility/mojom/ax_mode.mojom";
import "ui/accessibility/mojom/ax_relative_bounds.mojom";
import "ui/accessibility/mojom/ax_tree_id.mojom";
import "ui/accessibility/mojom/ax_tree_update.mojom";
import "ui/accessibility/mojom/ax_updates_and_events.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "third_party/blink/public/mojom/tokens/tokens.mojom";

struct LocationChanges {
  // ID of the object whose location is changing.
  int32 id;

  // The object's new location info.
  ax.mojom.AXRelativeBounds new_location;
};

struct HitTestResponse {
  // The frame token of the frame that got hit. If this is not equal to the
  // frame that the original hit test was called on, the client should do
  // another hit test on this frame.
  blink.mojom.FrameToken hit_frame_token;

  // The coordinates that should be used for the hit test on the child frame
  // indicated by |hit_frame_token|, accounting for the viewport. This is only
  // needed if |hit_frame_token| is not the same as the current frame's token.
  gfx.mojom.Point hit_frame_transformed_point;

  // The AXID of the accessibility node that got hit.
  int32 hit_node_id;
};

// Interface for accessibility messages sent from the renderer to the browser,
// implemented by RenderAccessibilityHostImpl and forwarded to
// RenderFrameHostImpl in the browser process.
interface RenderAccessibilityHost {
  // Sent to notify the browser about renderer accessibility events.
  //
  // The browser will respond by invoking the callback specified by the renderer
  // as part of once the original call has been processed, in order to notify
  // the renderer that it can send additional updates.
  //
  // |reset_token| parameter matches the value provided by the browser in the
  // most recent Reset() or SetMode(), so that the browser can filter out
  // obsolete messages.
  //
  // The accessibility information sent to the browser is dependent on both
  // the number of nodes in the DOM (and their accessibility metadata) as well
  // as the number of changes that generate events. Therefore, this payload can
  // become arbitrarily large.
  // TODO(crbug.com/1088484) tracks work to improve the payload size.
  [UnlimitedSize]
  HandleAXEvents(ax.mojom.AXUpdatesAndEvents events_and_updates,
                 uint32 reset_token) => ();

  // Sent to update the browser of the location of accessibility objects.
  // Similar to HandleAXEvents, the message size is also unbounded (though in
  // practice these message sizes are quite a bit smaller than HandleAXEvents).
  // TODO(crbug.com/1088484) tracks work to improve the payload size.
  //
  // |reset_token| parameter matches the value provided by the browser in the
  // most recent Reset() or SetMode(), so that the browser can filter out
  // obsolete messages.
  [UnlimitedSize]
  HandleAXLocationChanges(array<LocationChanges> changes, uint32 reset_token);
};

// Interface for accessibility messages sent from RenderFrameHostImpl in the
// browser process, implemented by the RenderAccessibilityManager object in the
// renderer process. This RenderAccessibilityManager object will be owned by the
// RenderFrameImpl object, which will keep it alive during its entire lifetime.
//
// This interface is used via an associated channel from RenderFrameHostImpl in
// the browser process, shared with other interfaces that accessibility-related
// messages need to maintain the order with like NavigationClient or LocalFrame.
interface RenderAccessibility {
  // Change the accessibility mode in the renderer process for a given frame to
  // match the one set for such frame from the browser process. |ax_mode| should
  // contain at least the ui::AXMode::kWebContents value to enable accessibility
  // support for web contents. See ui/accessibility/ax_mode.h for valid values.
  //
  // |reset_token| provides a value to return with future events, messages, etc.
  // so that the browser can filter out obsolete data.
  SetMode(ax.mojom.AXMode ax_mode, uint32 reset_token);

  // Kills the renderer. Sent when there is a fatal error in the accessibility
  // tree and the maximum number of resets has been hit.
  FatalError();

  // Relays a request from assistive technology to perform a hit test over the
  // accessibility object at the point passed via |point| in frame pixels.
  //
  // If the object hit doesn't have a child frame, and if |event_to_fire| is
  // set, the accessibility event will be emitted on the hit node with the
  // given request ID.
  //
  // Either way, the response contains the routing ID of the hit frame,
  // and the transformed point if the hit frame is a child frame.
  HitTest(gfx.mojom.Point point,
          ax.mojom.Event event_to_fire,
          int32 request_id)
      => (HitTestResponse? hit_test_response);

  // Relay a request from assistive technology to perform an action, such as
  // focusing or clicking on a node.
  PerformAction(ax.mojom.AXActionData action_data);

  // Tell the renderer to reset and send a new accessibility tree from scratch
  // because the browser is out of sync. It passes a sequential reset token.
  // This should be rare, and if we need to reset the same renderer too many
  // times we just kill it. After sending a reset, the browser ignores incoming
  // accessibility IPCs until it receives one with the matching reset token.
  // Conversely, it ignores IPCs with a reset token if it was not expecting a
  // reset.
  //
  // |reset_token| provides a value to return with future events, messages, etc.
  // so that the browser can filter out obsolete data.
  Reset(uint32 reset_token);
};