Bug 966591 - Part 5: Pass hit bounds to a11y code. r=surkov

This commit is contained in:
Rik Cabanier 2014-02-21 08:36:58 -05:00
parent 1aac581136
commit ea12ed62c9
2 changed files with 24 additions and 2 deletions

View File

@ -919,7 +919,27 @@ 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,

View File

@ -2395,7 +2395,9 @@ CanvasRenderingContext2D::AddHitRegion(const HitRegionOptions& options, ErrorRes
// 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