Commit a0c6d1b5 authored by Matt Reynolds's avatar Matt Reynolds Committed by Commit Bot

WebHID followup IDL changes

This modifies the WebHID IDL to address comments in a previous CL:

https://chromium-review.googlesource.com/c/chromium/src/+/1559344

In the prior commit, HIDReportItem held raw indices into the USB
string table (|stringMinimum| and |stringMaximum|). These members
are removed in favor of a new |strings| member which will return
the actual device data.

|designatorMinimum| and |designatorMaximum|, which held indices
into the physical descriptor table, are removed.

HIDReportItem held a |unit| member which described the unit factors
that make up the unit definition. The member was a 32-bit value composed
of 7 4-bit values and 4 reserved bits. These nibbles have been split
into separate members for the unit system and unit factor exponents.

In HIDCollectionInfo, the |reportIds| member is removed as its utility
is duplicated by the report information.

BUG=890096

Change-Id: I8403f9b7e275d97e58bb6c9ad73c2e2654f9d3d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1583427Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659157}
parent b6db23f3
...@@ -41,10 +41,6 @@ const HeapVector<Member<HIDReportInfo>>& HIDCollectionInfo::featureReports() ...@@ -41,10 +41,6 @@ const HeapVector<Member<HIDReportInfo>>& HIDCollectionInfo::featureReports()
return feature_reports_; return feature_reports_;
} }
const Vector<uint8_t>& HIDCollectionInfo::reportIds() const {
return report_ids_;
}
uint32_t HIDCollectionInfo::collectionType() const { uint32_t HIDCollectionInfo::collectionType() const {
return 0; return 0;
} }
......
...@@ -27,7 +27,6 @@ class HIDCollectionInfo : public ScriptWrappable { ...@@ -27,7 +27,6 @@ class HIDCollectionInfo : public ScriptWrappable {
const HeapVector<Member<HIDReportInfo>>& inputReports() const; const HeapVector<Member<HIDReportInfo>>& inputReports() const;
const HeapVector<Member<HIDReportInfo>>& outputReports() const; const HeapVector<Member<HIDReportInfo>>& outputReports() const;
const HeapVector<Member<HIDReportInfo>>& featureReports() const; const HeapVector<Member<HIDReportInfo>>& featureReports() const;
const Vector<uint8_t>& reportIds() const;
uint32_t collectionType() const; uint32_t collectionType() const;
void Trace(blink::Visitor* visitor) override; void Trace(blink::Visitor* visitor) override;
...@@ -37,7 +36,6 @@ class HIDCollectionInfo : public ScriptWrappable { ...@@ -37,7 +36,6 @@ class HIDCollectionInfo : public ScriptWrappable {
HeapVector<Member<HIDReportInfo>> input_reports_; HeapVector<Member<HIDReportInfo>> input_reports_;
HeapVector<Member<HIDReportInfo>> output_reports_; HeapVector<Member<HIDReportInfo>> output_reports_;
HeapVector<Member<HIDReportInfo>> feature_reports_; HeapVector<Member<HIDReportInfo>> feature_reports_;
Vector<uint8_t> report_ids_;
}; };
} // namespace blink } // namespace blink
......
...@@ -25,8 +25,4 @@ ...@@ -25,8 +25,4 @@
readonly attribute FrozenArray<HIDReportInfo> inputReports; readonly attribute FrozenArray<HIDReportInfo> inputReports;
readonly attribute FrozenArray<HIDReportInfo> outputReports; readonly attribute FrozenArray<HIDReportInfo> outputReports;
readonly attribute FrozenArray<HIDReportInfo> featureReports; readonly attribute FrozenArray<HIDReportInfo> featureReports;
// The 8-bit report IDs associated with this collection, in the order they
// were encountered in the report descriptor.
readonly attribute FrozenArray<octet> reportIds;
}; };
...@@ -10,8 +10,4 @@ HIDReportItem::HIDReportItem(const device::mojom::blink::HidReportItem& item) {} ...@@ -10,8 +10,4 @@ HIDReportItem::HIDReportItem(const device::mojom::blink::HidReportItem& item) {}
HIDReportItem::~HIDReportItem() {} HIDReportItem::~HIDReportItem() {}
void HIDReportItem::Trace(blink::Visitor* visitor) {
ScriptWrappable::Trace(visitor);
}
} // namespace blink } // namespace blink
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
#include "services/device/public/mojom/hid.mojom-blink.h" #include "services/device/public/mojom/hid.mojom-blink.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/heap/heap_allocator.h"
#include "third_party/blink/renderer/platform/heap/member.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace blink { namespace blink {
...@@ -24,23 +28,25 @@ class HIDReportItem : public ScriptWrappable { ...@@ -24,23 +28,25 @@ class HIDReportItem : public ScriptWrappable {
const Vector<uint32_t>& usages() const { return usages_; } const Vector<uint32_t>& usages() const { return usages_; }
uint32_t usageMinimum() const { return 0; } uint32_t usageMinimum() const { return 0; }
uint32_t usageMaximum() const { return 0; } uint32_t usageMaximum() const { return 0; }
uint32_t designatorMinimum() const { return 0; } const Vector<String>& strings() const { return strings_; }
uint32_t designatorMaximum() const { return 0; }
uint32_t stringMinimum() const { return 0; }
uint32_t stringMaximum() const { return 0; }
uint16_t reportSize() const { return 0; } uint16_t reportSize() const { return 0; }
uint16_t reportCount() const { return 0; } uint16_t reportCount() const { return 0; }
uint32_t unitExponent() const { return 0; } uint32_t unitExponent() const { return 0; }
uint32_t unit() const { return 0; } String unitSystem() const { return String(); }
int8_t unitFactorLengthExponent() const { return 0; }
int8_t unitFactorMassExponent() const { return 0; }
int8_t unitFactorTimeExponent() const { return 0; }
int8_t unitFactorTemperatureExponent() const { return 0; }
int8_t unitFactorCurrentExponent() const { return 0; }
int8_t unitFactorLuminousIntensityExponent() const { return 0; }
int32_t logicalMinimum() const { return 0; } int32_t logicalMinimum() const { return 0; }
int32_t logicalMaximum() const { return 0; } int32_t logicalMaximum() const { return 0; }
int32_t physicalMinimum() const { return 0; } int32_t physicalMinimum() const { return 0; }
int32_t physicalMaximum() const { return 0; } int32_t physicalMaximum() const { return 0; }
void Trace(blink::Visitor* visitor) override;
private: private:
Vector<uint32_t> usages_; Vector<uint32_t> usages_;
Vector<String> strings_;
}; };
} // namespace blink } // namespace blink
......
...@@ -6,6 +6,28 @@ ...@@ -6,6 +6,28 @@
// the report. // the report.
// https://wicg.github.io/webhid/index.html#report-descriptor // https://wicg.github.io/webhid/index.html#report-descriptor
// The HID specification allows a device to specify units in one of four
// standard unit systems. A device may also specify it is not using units, or is
// using a vendor-defined unit system. Each unit system corresponds to a set of
// units for length, mass, time, temperature, current, and luminous intensity.
// See the units table in section 6.2.2.7 of the Device Class Definition for
// HID, v1.11.
// https://www.usb.org/document-library/device-class-definition-hid-111
enum HIDUnitSystem {
// No unit system in use.
"none",
// Centimeter, gram, seconds, kelvin, ampere, candela.
"si-linear",
// Radians, gram, seconds, kelvin, ampere, candela.
"si-rotation",
// Inch, slug, seconds, Fahrenheit, ampere, candela.
"english-linear",
// Degrees, slug, seconds, Fahrenheit, ampere, candela.
"english-rotation",
"vendor-defined",
"reserved",
};
[ [
Exposed(Window WebHID), Exposed(Window WebHID),
SecureContext SecureContext
...@@ -39,18 +61,6 @@ ...@@ -39,18 +61,6 @@
readonly attribute unsigned long usageMinimum; readonly attribute unsigned long usageMinimum;
readonly attribute unsigned long usageMaximum; readonly attribute unsigned long usageMaximum;
// The minimum and maximum designator indices associated with this item. If
// there are no designators, both are set to zero.
// TODO(mattreynolds): Expose the designators instead of the indices.
readonly attribute unsigned long designatorMinimum;
readonly attribute unsigned long designatorMaximum;
// The minimum and maximum string indices associated with this item. If
// there are no designators, both are set to zero.
// TODO(mattreynolds): Expose the strings instead of the indices.
readonly attribute unsigned long stringMinimum;
readonly attribute unsigned long stringMaximum;
// The size of a single field described by this item, in bits. // The size of a single field described by this item, in bits.
readonly attribute unsigned short reportSize; readonly attribute unsigned short reportSize;
...@@ -62,12 +72,21 @@ ...@@ -62,12 +72,21 @@
// kilograms |unitExponent| would be 3 and for micrograms it would be -6. // kilograms |unitExponent| would be 3 and for micrograms it would be -6.
readonly attribute unsigned long unitExponent; readonly attribute unsigned long unitExponent;
// A value that specifies the unit factors that make up the units for this // The unit system determines which units are used for length, mass, time,
// report item. See the units table in section 6.2.2.7 of the Device Class // temperature, current, and luminous intensity. May be "none" if the values
// Definition for HID, v1.11. // for this report item are unitless.
// https://www.usb.org/document-library/device-class-definition-hid-111 readonly attribute HIDUnitSystem unitSystem;
// TODO(mattreynolds): Split this into its component nibbles.
readonly attribute unsigned long unit; // The following members determine the exponents for each factor of the
// unit definition. For instance, for acceleration all factors would have
// an exponent of 0 except |unitFactorLengthExponent| which would be 1 and
// |unitFactorTimeExponent| which would be -2.
readonly attribute byte unitFactorLengthExponent;
readonly attribute byte unitFactorMassExponent;
readonly attribute byte unitFactorTimeExponent;
readonly attribute byte unitFactorTemperatureExponent;
readonly attribute byte unitFactorCurrentExponent;
readonly attribute byte unitFactorLuminousIntensityExponent;
// The minimum and maximum values that may be represented by this input. A // The minimum and maximum values that may be represented by this input. A
// device with |hasNull| may report a value outside this range to indicate // device with |hasNull| may report a value outside this range to indicate
...@@ -79,4 +98,7 @@ ...@@ -79,4 +98,7 @@
// and |unitExponent|. // and |unitExponent|.
readonly attribute long physicalMinimum; readonly attribute long physicalMinimum;
readonly attribute long physicalMaximum; readonly attribute long physicalMaximum;
// The strings associated with this item.
readonly attribute FrozenArray<DOMString> strings;
}; };
...@@ -2369,7 +2369,6 @@ interface HIDCollectionInfo ...@@ -2369,7 +2369,6 @@ interface HIDCollectionInfo
getter featureReports getter featureReports
getter inputReports getter inputReports
getter outputReports getter outputReports
getter reportIds
getter usage getter usage
getter usagePage getter usagePage
method constructor method constructor
...@@ -2405,8 +2404,6 @@ interface HIDReportInfo ...@@ -2405,8 +2404,6 @@ interface HIDReportInfo
method constructor method constructor
interface HIDReportItem interface HIDReportItem
attribute @@toStringTag attribute @@toStringTag
getter designatorMaximum
getter designatorMinimum
getter hasNull getter hasNull
getter isAbsolute getter isAbsolute
getter isArray getter isArray
...@@ -2417,10 +2414,15 @@ interface HIDReportItem ...@@ -2417,10 +2414,15 @@ interface HIDReportItem
getter physicalMinimum getter physicalMinimum
getter reportCount getter reportCount
getter reportSize getter reportSize
getter stringMaximum getter strings
getter stringMinimum
getter unit
getter unitExponent getter unitExponent
getter unitFactorCurrentExponent
getter unitFactorLengthExponent
getter unitFactorLuminousIntensityExponent
getter unitFactorMassExponent
getter unitFactorTemperatureExponent
getter unitFactorTimeExponent
getter unitSystem
getter usageMaximum getter usageMaximum
getter usageMinimum getter usageMinimum
getter usages getter usages
......
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