Skip to content

Commit

Permalink
constrain AccessiblePeer sibling bounds to the Display div bounds, see
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Dec 2, 2019
1 parent 4b00865 commit 2c6b0d4
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions js/accessibility/AccessiblePeer.js
Original file line number Diff line number Diff line change
Expand Up @@ -888,26 +888,37 @@ define( require => {
if ( scratchGlobalBounds.isFinite() ) {
scratchGlobalBounds.transform( this.accessibleInstance.transformTracker.getMatrix() );

let clientDimensions = getClientDimensions( this._primarySibling );
let clientWidth = clientDimensions.width;
let clientHeight = clientDimensions.height;

if ( clientWidth > 0 && clientHeight > 0 ) {
scratchSiblingBounds.setMinMax( 0, 0, clientWidth, clientHeight );
scratchSiblingBounds.transform( getCSSMatrix( clientWidth, clientHeight, scratchGlobalBounds ) );
setClientBounds( this._primarySibling, scratchSiblingBounds );
}
// no need to position if the node is fully outside of the Display bounds (out of view)
const displayBounds = this.display.bounds;
if ( displayBounds.intersectsBounds( scratchGlobalBounds ) ) {

// Constrain the global bounds to Display bounds so that center of the sibling element
// is always in the Display. We may miss input if the center of the Node is outside
// the Display, where VoiceOver would otherwise send pointer events.
scratchGlobalBounds.constrainBounds( displayBounds );

if ( this.labelSibling ) {
clientDimensions = getClientDimensions( this._labelSibling );
clientWidth = clientDimensions.width;
clientHeight = clientDimensions.height;
let clientDimensions = getClientDimensions( this._primarySibling );
let clientWidth = clientDimensions.width;
let clientHeight = clientDimensions.height;

if ( clientHeight > 0 && clientWidth > 0 ) {
if ( clientWidth > 0 && clientHeight > 0 ) {
scratchSiblingBounds.setMinMax( 0, 0, clientWidth, clientHeight );
scratchSiblingBounds.transform( getCSSMatrix( clientWidth, clientHeight, scratchGlobalBounds ) );
setClientBounds( this._labelSibling, scratchSiblingBounds );
setClientBounds( this._primarySibling, scratchSiblingBounds );
}

if ( this.labelSibling ) {
clientDimensions = getClientDimensions( this._labelSibling );
clientWidth = clientDimensions.width;
clientHeight = clientDimensions.height;

if ( clientHeight > 0 && clientWidth > 0 ) {
scratchSiblingBounds.setMinMax( 0, 0, clientWidth, clientHeight );
scratchSiblingBounds.transform( getCSSMatrix( clientWidth, clientHeight, scratchGlobalBounds ) );
setClientBounds( this._labelSibling, scratchSiblingBounds );
}
}

}
}
}
Expand Down

0 comments on commit 2c6b0d4

Please sign in to comment.