Bug 1473453 - Part 1: a11y: assert `hitregion` property is always null or true. r?surkov
Fix clang-tidy warning about bool pointers:
[misc-bool-pointer-implicit-conversion] accessible/generic/Accessible.cpp:644:9: warning: dubious check of 'bool *' against 'nullptr', did you mean to dereference it?
The `hitregion` property is always null or points to a true bool, set here:
https://searchfox.org/mozilla-central/rev/6ef785903fee6c0b16a1eab79d722373d940fd78/dom/canvas/CanvasRenderingContext2D.cpp#3936-3937
The `hitregion` property used to be an nsRect pointer:
https://searchfox.org/mozilla-central/diff/c797577640f306df87e8c32313c5b826d1e58a9b/accessible/src/generic/Accessible.cpp#928
MozReview-Commit-ID: HYlAnMyaitB
--- a/accessible/generic/Accessible.cpp
+++ b/accessible/generic/Accessible.cpp
@@ -634,17 +634,20 @@ Accessible::ChildAtPoint(int32_t aX, int
return accessible;
}
nsRect
Accessible::RelativeBounds(nsIFrame** aBoundingFrame) const
{
nsIFrame* frame = GetFrame();
if (frame && mContent) {
- bool* hasHitRegionRect = static_cast<bool*>(mContent->GetProperty(nsGkAtoms::hitregion));
+ bool* pHasHitRegionRect = static_cast<bool*>(mContent->GetProperty(nsGkAtoms::hitregion));
+ MOZ_ASSERT(pHasHitRegionRect == nullptr ||
+ *pHasHitRegionRect, "hitregion property is always null or true");
+ bool hasHitRegionRect = pHasHitRegionRect != nullptr && *pHasHitRegionRect;
if (hasHitRegionRect && mContent->IsElement()) {
// This is for canvas fallback content
// Find a canvas frame the found hit region is relative to.
nsIFrame* canvasFrame = frame->GetParent();
if (canvasFrame) {
canvasFrame = nsLayoutUtils::GetClosestFrameOfType(
canvasFrame, LayoutFrameType::HTMLCanvas);