Limit the semantic nodes ID range to 2^16 (#29928)
This PR limits the framework generated semantic node IDs to be smaller than 2^16, this allows to safely generate semantic node in the engine with IDs >= 2^16 avoiding ID collision (which is done in flutter/engine#8250).
This commit is contained in:
@@ -1105,9 +1105,17 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
|
||||
attach(owner);
|
||||
}
|
||||
|
||||
|
||||
// The maximal semantic node identifier generated by the framework.
|
||||
//
|
||||
// The identifier range for semantic node IDs is split into 2, the least significant 16 bits are
|
||||
// reserved for framework generated IDs(generated with _generateNewId), and most significant 32
|
||||
// bits are reserved for engine generated IDs.
|
||||
static const int _maxFrameworkAccessibilityIdentifier = (1<<16) - 1;
|
||||
|
||||
static int _lastIdentifier = 0;
|
||||
static int _generateNewId() {
|
||||
_lastIdentifier += 1;
|
||||
_lastIdentifier = (_lastIdentifier + 1) % _maxFrameworkAccessibilityIdentifier;
|
||||
return _lastIdentifier;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user