Files
react-native/ReactAndroid/src/main/java/com/facebook/react/flat/NodeRegion.java
T
Denis KoroskinandAhmed El-Helw 381bf1b76f Implement TextNodeRegion
Summary: NodeRegion is only able to describe a rectangular region for touch, which is not good enough for text, where we want to be able to assign different touch ids to individual words (and those can span more than one line and in general have non-rectangular structure). This diff adds TextNodeRegion which inserts additional markers into text Layout to allow individual words to have unique react tags.

Reviewed By: ahmedre

Differential Revision: D2757387
2016-12-19 13:40:17 -08:00

38 lines
1.1 KiB
Java

/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.facebook.react.flat;
/* package */ class NodeRegion {
/* package */ static final NodeRegion[] EMPTY_ARRAY = new NodeRegion[0];
/* package */ static final NodeRegion EMPTY = new NodeRegion(0, 0, 0, 0, -1);
/* package */ final float mLeft;
/* package */ final float mTop;
/* package */ final float mRight;
/* package */ final float mBottom;
/* package */ final int mTag;
/* package */ NodeRegion(float left, float top, float right, float bottom, int tag) {
mLeft = left;
mTop = top;
mRight = right;
mBottom = bottom;
mTag = tag;
}
/* package */ final boolean withinBounds(float touchX, float touchY) {
return mLeft <= touchX && touchX < mRight && mTop <= touchY && touchY < mBottom;
}
/* package */ int getReactTag(float touchX, float touchY) {
return mTag;
}
}