Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(skia): make UIElement.HitTest strictly stronger than UIElement.IsViewHit #17948

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ramezgerges
Copy link
Contributor

GitHub Issue (If applicable): followup to #16201

PR Type

What kind of change does this PR introduce?

What is the current behavior?

What is the new behavior?

PR Checklist

Please check if your PR fulfills the following requirements:

Other information

Internal Issue (If applicable):

@github-actions github-actions bot added the area/skia ✏️ Categorizes an issue or PR as relevant to Skia label Aug 15, 2024
@unodevops
Copy link
Contributor

🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-17948/index.html

Comment on lines +300 to 305
// This shouldn't be needed, but due to the way we implement Popups, we might
// need to make Popups not hit-testable even if the PopupPanel has a Background.
#if __SKIA__
internal override bool HitTest(Point point) => IsViewHit();
#endif
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really feeling comfortable with this. I'd personally prefer if we still keep the HitTestability.Visible check in SearchDownForTopMostElementAt. Then at some point we can try to remove IsViewHit completely, at least on Skia. That's kinda my personal preference.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do agree that is weird ... why we cannot rely on the Visual here?

Also in all cases, please remove the #if __SKIA__. Even if not used on other platforms yet, the code should be shared to allow easier maintenance.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relying on Visual here is probably buggy due to bugs in popup implementation itself that will need to be their own separate work. In this case, IsViewHit can return false while the visual can actually hit test. This basically makes me more convinced into keeping the check in the VisualTreeHelper as done with #17973. My opinion here is that #17973 is enough for now. It's not worth the hassle around trying to force HitTest to be a stronger condition.

For now, the only place we know it's not stronger is PopupPanel, and this PR forces it to be strongly by basically just calling IsViewHit.

(btw, if we proceeded with this PR, it will be a better idea to return IsViewHit() && base.HitTest(point) I think)

@unodevops
Copy link
Contributor

🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-17948/index.html

@github-actions github-actions bot removed the area/skia ✏️ Categorizes an issue or PR as relevant to Skia label Aug 15, 2024
@ramezgerges
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@unodevops
Copy link
Contributor

🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-17948/index.html

@unodevops
Copy link
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-17948/index.html

if (elementHitTestVisibility == HitTestability.Visible && renderingBounds.Contains(testPosition))
#endif
{
// UIElement.HitTest should be a stronger condition than elementHitTestVisibility == HitTestability.Visible
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UIElement.HitTest just does Visual hit testing, which isn't aware of whether the UIElement's background is NULL or not. Aren't we creating transparent background in both cases? Also, what if the user gets the Visual and modifies the background, in this case they are not the same. I tend to think we should really restore elementHitTestVisibility == HitTestability.Visible check

Copy link
Member

@dr1rrb dr1rrb Aug 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's the case so far, but the Visual could be aware if the background is null a pixel has not been painted, or not (even if it has been painted using with transparent color). If so, the elementHitTestVisibility == HitTestability.Visible check would indeed only be about what hit-testability we push to the native element and therefor should be less restrictive than the IsViewHit().


return element.Background != null;
}
internal override bool IsViewHit() => ((IBorderInfoProvider)this).IsViewHit();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may change behavior on non-Skia. It was already not correct behavior, but now will be incorrect in a different way, I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could guard this with #if __SKIA__, but the change makes sense in general I think, so I would say it's better to change the behaviour on non-skia targets even if it's still not accurate.

@jeromelaban jeromelaban marked this pull request as draft August 26, 2024 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants