Skip to content

Commit

Permalink
Merge two PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongwuzw committed Jul 31, 2024
1 parent 450aaf1 commit d7f8823
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,11 @@ ShadowNode::Shared LayoutableShadowNode::findNodeAtPoint(
auto transform = layoutableShadowNode->getTransform();
auto frame = layoutableShadowNode->getLayoutMetrics().frame;
auto transformedFrame = frame * transform;
auto isPointInside = transformedFrame.containsPoint(point);
auto isPointInside = false;
auto newPoint = Point();
auto inversionTransform = transform;

// Fast path: Handle horizontal/vertical inversion
if (Transform::isVerticalInversion(transform) ||
Transform::isHorizontalInversion(transform)) {
auto centerX =
Expand All @@ -285,16 +288,27 @@ ShadowNode::Shared LayoutableShadowNode::findNodeAtPoint(

point.x = centerX + relativeX;
point.y = centerY + relativeY;

isPointInside = transformedFrame.containsPoint(point);
newPoint = point - transformedFrame.origin -
layoutableShadowNode->getContentOriginOffset(false);
} else {
// Slow path: Handle translation/rotation .. etc.
if (transform.matrix != Transform::Identity().matrix &&
transform.getInversion(inversionTransform)) {
point = inversionTransform.applyWithRect(point, frame);
}
isPointInside = frame.containsPoint(point);
newPoint = point - frame.origin -
layoutableShadowNode->getContentOriginOffset(false);
}

if (!isPointInside) {
return nullptr;
} else if (!layoutableShadowNode->canChildrenBeTouchTarget()) {
return node;
}

auto newPoint = point - transformedFrame.origin -
layoutableShadowNode->getContentOriginOffset(false);

auto sortedChildren = node->getChildren();
std::stable_sort(
sortedChildren.begin(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ struct RectangleEdges {
return left == top && left == right && left == bottom;
}

bool isZero() const noexcept {
return left == 0 && top == 0 && right == 0 && bottom == 0;
}

static const RectangleEdges<T> ZERO;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,7 @@ Size operator*(const Size& size, const Transform& transform) {
return result;
}

bool Transform::inv() {
if (*this == Transform::Identity()) {
return true;
}

bool Transform::getInversion(Transform& transform) {
double inv[16], det;
int i;
auto m = this->matrix;
Expand Down Expand Up @@ -563,7 +559,7 @@ bool Transform::inv() {
det = 1.0 / det;

for (i = 0; i < 16; i++)
this->matrix[i] = inv[i] * det;
transform.matrix[i] = inv[i] * det;

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ struct Transform {
*/
static Transform Skew(Float x, Float y);

bool inv();
bool getInversion(Transform& transform);

/*
* Returns a transform that rotates by `angle` radians along the given axis.
Expand Down

0 comments on commit d7f8823

Please sign in to comment.