Unverified Commit f652f018 authored by Amir Hardon's avatar Amir Hardon Committed by GitHub

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).
parent 7ea7d8d0
......@@ -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;
}
......
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