mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
b52928c484
Summary: Before this patch, we only collected virtual nodes in NodeRegions, because NodeRegions are only needed to implement ReactCompoundView.reactTargetForTouch() which is only interested in virtual nodes. In the next patch, FlatViewGroup will implement ReactCompoundViewGroup interface which requires knowledge of both virtual and non-virtual children. As a step towards that, we need to include non-virtual nodes in NodeRegions. This patch is implementing that. By itself, it should have not cause any changes in application behavior: we add non-virtual nodes to NodeRegions and mark them as non-virtual, then skip all non-virtual nodes in reactTagForTouch(). Reviewed By: ahmedre Differential Revision: D3018047
46 lines
1.2 KiB
Java
46 lines
1.2 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, false);
|
|
|
|
/* package */ final float mLeft;
|
|
/* package */ final float mTop;
|
|
/* package */ final float mRight;
|
|
/* package */ final float mBottom;
|
|
/* package */ final int mTag;
|
|
/* package */ final boolean mIsVirtual;
|
|
|
|
/* package */ NodeRegion(
|
|
float left,
|
|
float top,
|
|
float right,
|
|
float bottom,
|
|
int tag,
|
|
boolean isVirtual) {
|
|
mLeft = left;
|
|
mTop = top;
|
|
mRight = right;
|
|
mBottom = bottom;
|
|
mTag = tag;
|
|
mIsVirtual = isVirtual;
|
|
}
|
|
|
|
/* 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;
|
|
}
|
|
}
|