File: README.md

package info (click to toggle)
qtwebengine-opensource-src 5.15.13%2Bdfsg-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,112,448 kB
  • sloc: cpp: 13,167,885; ansic: 4,228,702; javascript: 1,909,649; python: 554,805; asm: 529,966; xml: 496,619; java: 151,702; objc: 80,776; perl: 73,361; sh: 71,208; cs: 30,383; makefile: 20,779; yacc: 9,120; tcl: 8,394; php: 5,896; sql: 5,473; pascal: 4,510; lex: 2,884; lisp: 2,727; ruby: 559; awk: 200; sed: 40
file content (150 lines) | stat: -rw-r--r-- 9,245 bytes parent folder | download | duplicates (5)
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
# Sensors

`services/device/generic_sensor` contains the platform-specific parts of the Sensor APIs
implementation.

Sensors Mojo interfaces are defined in the `services/device/public/mojom` subdirectory.

## Web-exposed Interfaces

### [Generic Sensors](https://www.w3.org/TR/generic-sensor/)

The Generic Sensors API is implemented in `third_party/blink/renderer/modules/sensor` and exposes the following sensor types as JavaScript objects:

* [AbsoluteOrientationSensor] → ABSOLUTE_ORIENTATION_QUATERNION
* [Accelerometer] → ACCELEROMETER
* [AmbientLightSensor] → AMBIENT_LIGHT
* [Gyroscope] → GYROSCOPE
* [LinearAccelerationSensor] → LINEAR_ACCELEROMETER
* [Magnetometer] → MAGNETOMETER
* [RelativeOrientationSensor] → RELATIVE_ORIENTATION_QUATERNION

[AbsoluteOrientationSensor]: ../../../third_party/blink/renderer/modules/sensor/absolute_orientation_sensor.idl
[Accelerometer]: ../../../third_party/blink/renderer/modules/sensor/accelerometer.idl
[AmbientLightSensor]: ../../../third_party/blink/renderer/modules/sensor/ambient_light_sensor.idl
[Gyroscope]: ../../../third_party/blink/renderer/modules/sensor/gyroscope.idl
[LinearAccelerationSensor]: ../../../third_party/blink/renderer/modules/sensor/linear_acceleration_sensor.idl
[Magnetometer]: ../../../third_party/blink/renderer/modules/sensor/magnetometer.idl
[RelativeOrientationSensor]: ../../../third_party/blink/renderer/modules/sensor/relative_orientation_sensor.idl

### [DeviceOrientation Events](https://www.w3.org/TR/orientation-event/)

The DeviceOrientation Events API is implemented in `third_party/blink/renderer/modules/device_orientation` and exposes two events based on the following sensors:

* [DeviceMotionEvent]
  * ACCELEROMETER: populates the `accelerationIncludingGravity` field
  * LINEAR_ACCELEROMETER: populates the `acceleration` field
  * GYROSCOPE: populates the `rotationRate` field
* [DeviceOrientationEvent]
  * ABSOLUTE_ORIENTATION_EULER_ANGLES (when a listener for the `'deviceorientationabsolute'` event is added)
  * RELATIVE_ORIENTATION_EULER_ANGLES (when a listener for the `'deviceorientation'` event is added)

[DeviceMotionEvent]: ../../../third_party/blink/renderer/modules/device_orientation/device_motion_event.idl
[DeviceOrientationEvent]: ../../../third_party/blink/renderer/modules/device_orientation/device_orientation_event.idl

The content renderer layer is located in `third_party/blink/renderer/modules/device_orientation`.

Testing:

* Browser tests are located in `content/browser/device_sensors`.
* Layout tests are located in `third_party/WebKit/LayoutTests/device_orientation`.
* Web platform tests are located in `third_party/WebKit/LayoutTests/external/wpt/orientation-event` and are a mirror of the [web-platform-tests GitHub repository](https://github.com/web-platform-tests/wpt).

## Permissions

The device service provides no support for permission checks. When the render process requests access to a sensor type this request is proxied through the browser process by [SensorProviderProxyImpl] which is responsible for checking the permissions granted to the requesting origin.

[SensorProviderProxyImpl]: ../../../content/browser/generic_sensor/sensor_provider_proxy_impl.h

## Platform Support

Support for the SensorTypes defined by the Mojo interface is summarized in this
table. An empty cell indicates that the sensor type is not supported on that
platform.

| SensorType                        | Android                   | Linux                                 | macOS                                 | Windows                                   |
| --------------------------------- | ------------------------- | ------------------------------------- | ------------------------------------- | ----------------------------------------- |
| AMBIENT_LIGHT                     | TYPE_LIGHT                | in_illuminance                        | AppleLMUController                    | Yes                                       |
| PROXIMITY                         |                           |                                       |                                       |                                           |
| ACCELEROMETER                     | TYPE_ACCELEROMETER        | in_accel                              | SMCMotionSensor                       | Yes                                       |
| LINEAR_ACCELEROMETER              | See below                 | ACCELEROMETER (*)                     |                                       | ACCELEROMETER (*)                         |
| GYROSCOPE                         | TYPE_GYROSCOPE            | in_anglvel                            |                                       | Yes                                       |
| MAGNETOMETER                      | TYPE_MAGNETIC_FIELD       | in_magn                               |                                       | Yes                                       |
| PRESSURE                          |                           |                                       |                                       |                                           |
| ABSOLUTE_ORIENTATION_EULER_ANGLES | See below                 | ACCELEROMETER and MAGNETOMETER (*)    |                                       | Yes                                       |
| ABSOLUTE_ORIENTATION_QUATERNION   | See below                 | ABSOLUTE_ORIENTATION_EULER_ANGLES (*) |                                       | Yes                                       |
| RELATIVE_ORIENTATION_EULER_ANGLES | See below                 | ACCELEROMETER and GYROSCOPE (*)       | ACCELEROMETER (*)                     |                                           |
|                                   |                           | or ACCELEROMETER (*)                  |                                       |                                           |
| RELATIVE_ORIENTATION_QUATERNION   | TYPE_GAME_ROTATION_VECTOR | RELATIVE_ORIENTATION_EULER_ANGLES (*) | RELATIVE_ORIENTATION_EULER_ANGLES (*) |                                           |

(Note: "*" means the sensor type is provided by sensor fusion.)

### Android

Sensors are implemented by passing through values provided by the
[Sensor](https://developer.android.com/reference/android/hardware/Sensor.html)
class. The TYPE_* values in the below descriptions correspond to the integer
constants from the android.hardware.Sensor used to provide data for a
SensorType.

For LINEAR_ACCELEROMETER, the following sensor fallback is used:
1. Use TYPE_LINEAR_ACCELERATION directly
2. ACCELEROMETER, with a low-pass filter to isolate the effect of gravity

For ABSOLUTE_ORIENTATION_EULER_ANGLES, the following sensor fallback is used:
1. ABSOLUTE_ORIENTATION_QUATERNION (if it uses TYPE_ROTATION_VECTOR
     directly)
2. Combination of ACCELEROMETER and MAGNETOMETER

For ABSOLUTE_ORIENTATION_QUATERNION, the following sensor fallback is used:
1. Use TYPE_ROTATION_VECTOR directly
2. ABSOLUTE_ORIENTATION_EULER_ANGLES

For RELATIVE_ORIENTATION_EULER_ANGLES, converts the data produced by
RELATIVE_ORIENTATION_QUATERNION to euler angles.

### Linux (and Chrome OS)

Sensors are implemented by reading values from the IIO subsystem. The values in
the "Linux" column of the table above are the prefix of the sysfs files Chrome
searches for to provide data for a SensorType. The
ABSOLUTE_ORIENTATION_EULER_ANGLES sensor type is provided by interpreting the
value that can be read from the ACCELEROMETER and MAGNETOMETER. The
ABSOLUTE_ORIENTATION_QUATERNION sensor type is provided by interpreting the
value that can be read from the ABSOLUTE_ORIENTATION_EULER_ANGLES. The
RELATIVE_ORIENTATION_EULER_ANGLES sensor type is provided by interpreting the
value that can be read from the ACCELEROMETER and GYROSCOPE, or ACCELEROMETER.
The RELATIVE_ORIENTATION_QUATERNION sensor type is provided by interpreting the
value that can be read from the RELATIVE_ORIENTATION_EULER_ANGLES.
LINEAR_ACCELEROMETER sensor type is provided by implementing a low-pass-filter
over the values returned by the ACCELEROMETER in order to remove the
contribution of the gravitational force.

### macOS

On this platform there is limited support for sensors. The AMBIENT_LIGHT sensor
type is provided by interpreting the value that can be read from the LMU. The
ACCELEROMETER sensor type is provided by interpreting the value that can be read
from the SMCMotionSensor. The RELATIVE_ORIENTATION_EULER_ANGLES sensor type is
provided by interpreting the value that can be read from the ACCELEROMETER. The
RELATIVE_ORIENTATION_QUATERNION sensor type is provided by interpreting the
value that can be read from the RELATIVE_ORIENTATION_EULER_ANGLES.

### Windows

Please refer to this [document](windows/README.md).

## Testing

Sensors platform unit tests are located in the current directory and its
subdirectories.

The sensors unit tests file for Android is
`android/junit/src/org/chromium/device/sensors/PlatformSensorAndProviderTest.java`.

Sensors browser tests are located in `content/test/data/generic_sensor`.

## Design Documents

Please refer to the [design documentation](https://docs.google.com/document/d/1Ml65ZdW5AgIsZTszk4mD_ohr40pcrdVFOIf0ZtWxDv0)
for more details.