Bug 1473453 - Part 1: a11y: assert `hitregion` property is always null or true. r?surkov draft
authorChris Peterson <cpeterson@mozilla.com>
Wed, 04 Jul 2018 14:39:57 -0700
changeset 814372 b9e8b65d2db1ec517ee5bcc7a3a1aad95585433f
parent 814369 90be04d99fc7941cb9b7186bf5f95e184a4e989a
child 814373 0de6b76c3614bb60408fce2236f98a0cae348bb1
push id115173
push usercpeterson@mozilla.com
push dateThu, 05 Jul 2018 03:25:42 +0000
reviewerssurkov
bugs1473453
milestone63.0a1
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
accessible/generic/Accessible.cpp
--- 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);