Bug 966591 - Part 5: Pass hit bounds to a11y code. r=surkov
☠☠ backed out by fb8597ff68ea ☠ ☠
authorRik Cabanier <cabanier@adobe.com>
Fri, 21 Feb 2014 08:36:58 -0500
changeset 170251 9ac56da106462eec6ea78bbd5d335c181b74ac67
parent 170250 81ba9bddd84e9ff432d81b4a4bf82f26d4e573bb
child 170252 c428b424ef95c6915256592b79521f83ba8761cf
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewerssurkov
bugs966591
milestone30.0a1
Bug 966591 - Part 5: Pass hit bounds to a11y code. r=surkov
accessible/src/generic/Accessible.cpp
content/canvas/src/CanvasRenderingContext2D.cpp
--- a/accessible/src/generic/Accessible.cpp
+++ b/accessible/src/generic/Accessible.cpp
@@ -914,17 +914,37 @@ Accessible::GetDeepestChildAtPoint(int32
   NS_IF_ADDREF(*aAccessible = ChildAtPoint(aX, aY, eDeepestChild));
   return NS_OK;
 }
 
 void
 Accessible::GetBoundsRect(nsRect& aTotalBounds, nsIFrame** aBoundingFrame)
 {
   nsIFrame* frame = GetFrame();
-  if (frame) {
+  if (frame && mContent) {
+    nsRect* hitRegionRect = static_cast<nsRect*>(mContent->GetProperty(nsGkAtoms::hitregion));
+
+    if (hitRegionRect) {
+      // This is for canvas fallback content
+      // Find a canvas frame the found hit region is relative to.
+      nsIFrame* canvasFrame = frame->GetParent();
+      while (canvasFrame && (canvasFrame->GetType() != nsGkAtoms::HTMLCanvasFrame))
+        canvasFrame = canvasFrame->GetParent();
+
+      // make the canvas the bounding frame
+      if (canvasFrame) {
+        *aBoundingFrame = canvasFrame;
+
+        nsPresContext* presContext = mDoc->PresContext();
+        aTotalBounds = *hitRegionRect;
+
+        return;
+      }
+    }
+
     *aBoundingFrame = nsLayoutUtils::GetContainingBlockForClientRect(frame);
     aTotalBounds = nsLayoutUtils::
       GetAllInFlowRectsUnion(frame, *aBoundingFrame,
                              nsLayoutUtils::RECTS_ACCOUNT_FOR_TRANSFORMS);
   }
 }
 
 /* void getBounds (out long x, out long y, out long width, out long height); */
--- a/content/canvas/src/CanvasRenderingContext2D.cpp
+++ b/content/canvas/src/CanvasRenderingContext2D.cpp
@@ -2390,17 +2390,19 @@ CanvasRenderingContext2D::AddHitRegion(c
   EnsureUserSpacePath(CanvasWindingRule::Nonzero);
   if(!mPath) {
     error.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
     return;
   }
 
   // get the bounds of the current path. They are relative to the canvas
   mgfx::Rect bounds(mPath->GetBounds(mTarget->GetTransform()));
-  nsRect* nsBounds = new nsRect(bounds.x, bounds.y, bounds.width, bounds.height);
+  gfxRect rect(bounds.x, bounds.y, bounds.width, bounds.height);
+  nsRect* nsBounds = new nsRect();
+  *nsBounds = nsLayoutUtils::RoundGfxRectToAppRect(rect, AppUnitsPerCSSPixel());
   options.mControl->SetProperty(nsGkAtoms::hitregion, nsBounds, ReleaseBBoxPropertyValue, true);
 
   // finally, add the region to the list if it has an ID
   if (options.mId.Length() != 0) {
     mHitRegionsOptions.PutEntry(options.mId)->mElement = options.mControl;
   }
 }