Bug 966591 - Part 5: Pass hit bounds to a11y code. r=surkov
authorRik Cabanier <cabanier@adobe.com>
Fri, 21 Feb 2014 08:36:58 -0500
changeset 187589 ec50b53150cac0986eff775cd7beb4c2c46e6fc5
parent 187588 9779b2fd4ec37d8da972ce9ef78e106ae7ecaf55
child 187590 fc089133d229dc28a1c8af60fa28597efe07973b
push id3503
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:51:11 +0000
treeherdermozilla-beta@c95ac01e332e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs966591
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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;
   }
 }