| // Copyright 2015 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. |
| |
| [DartPackage="sky_services"] |
| module semantics; |
| |
| enum SemanticAction { |
| TAP, |
| LONG_PRESS, |
| SCROLL_LEFT, |
| SCROLL_RIGHT, |
| SCROLL_UP, |
| SCROLL_DOWN, |
| INCREASE, |
| DECREASE, |
| }; |
| |
| struct SemanticsNode { |
| uint32 id; |
| |
| // A null field means "unchanged since last time". |
| SemanticFlags? flags; |
| SemanticStrings? strings; |
| SemanticGeometry? geometry; |
| // TODO(abarth): Switch to array<SemanticAction> once that works. |
| // See https://github.com/domokit/mojo/issues/799 |
| array<int32>? actions; |
| array<SemanticsNode>? children; |
| }; |
| |
| struct SemanticFlags { |
| // This is intended to just be booleans, so that it can be extended |
| // over time yet still be packed tightly. |
| bool has_checked_state = false; // whether is_checked is relevant |
| bool is_checked = false; |
| }; |
| |
| struct SemanticStrings { |
| // This is intended to just be Strings. |
| string label; |
| }; |
| |
| struct SemanticGeometry { |
| // A SemanticsNode defines a rectangle in a cartesian coordinate |
| // space within which it is potentially interactive. |
| |
| // The transform from the coordinate space of the parent |
| // SemanticsNode (or the application's display area, if this is the |
| // root node) to this SemanticsNode's coordinate space, described as |
| // a 4x4 matrix, with values in column-major order. The array must |
| // have exactly 16 values. |
| // This can be left unset to imply the identity matrix. |
| array<float, 16>? transform; |
| |
| // The position and size of the potentially interactive rectangle in the |
| // SemanticsNode's coordinate space. |
| // If the width or height are zero, then the node should be treated |
| // as absent for most purposes. The node may, however, have further |
| // children. |
| float left; |
| float top; |
| float width; |
| float height; |
| }; |
| |
| interface SemanticsListener { |
| // The engine side, invoked from the app. |
| UpdateSemanticsTree(array<SemanticsNode> nodes); |
| }; |
| |
| [ServiceName="semantics::SemanticsServer"] |
| interface SemanticsServer { |
| // The app side, invoked from the engine. |
| AddSemanticsListener(SemanticsListener listener); |
| PerformAction(uint32 nodeID, SemanticAction action); |
| }; |