diff --git a/accessible/html/HTMLImageMapAccessible.cpp b/accessible/html/HTMLImageMapAccessible.cpp index cf9e0dfb1db7..025f9342b0d5 100644 --- a/accessible/html/HTMLImageMapAccessible.cpp +++ b/accessible/html/HTMLImageMapAccessible.cpp @@ -14,6 +14,7 @@ #include "nsImageFrame.h" #include "nsImageMap.h" #include "nsIURI.h" +#include "nsLayoutUtils.h" #include "mozilla/dom/HTMLAreaElement.h" using namespace mozilla::a11y; @@ -174,6 +175,7 @@ nsRect HTMLAreaAccessible::RelativeBounds(nsIFrame** aBoundingFrame) const { nsRect bounds; nsresult rv = map->GetBoundsForAreaContent(mContent, bounds); + if (NS_FAILED(rv)) return nsRect(); // XXX Areas are screwy; they return their rects as a pair of points, one pair @@ -182,3 +184,25 @@ nsRect HTMLAreaAccessible::RelativeBounds(nsIFrame** aBoundingFrame) const { bounds.SizeTo(bounds.Width() - bounds.X(), bounds.Height() - bounds.Y()); return bounds; } + +nsRect HTMLAreaAccessible::ParentRelativeBounds() { + nsIFrame* boundingFrame = nullptr; + nsRect relativeBoundsRect = RelativeBounds(&boundingFrame); + + nsIFrame* parentBoundingFrame = nullptr; + if (mParent) { + parentBoundingFrame = mParent->GetFrame(); + } + + if (!parentBoundingFrame) { + // if we can't get the bounding frame, use the pres shell root for the + // bounding frame RelativeBounds returned + parentBoundingFrame = + nsLayoutUtils::GetContainingBlockForClientRect(boundingFrame); + } + + nsLayoutUtils::TransformRect(boundingFrame, parentBoundingFrame, + relativeBoundsRect); + + return relativeBoundsRect; +} diff --git a/accessible/html/HTMLImageMapAccessible.h b/accessible/html/HTMLImageMapAccessible.h index cb7d9c0ed01b..cbe7fdc4b361 100644 --- a/accessible/html/HTMLImageMapAccessible.h +++ b/accessible/html/HTMLImageMapAccessible.h @@ -58,6 +58,7 @@ class HTMLAreaAccessible final : public HTMLLinkAccessible { virtual LocalAccessible* LocalChildAtPoint( int32_t aX, int32_t aY, EWhichChildAtPoint aWhichChild) override; virtual nsRect RelativeBounds(nsIFrame** aBoundingFrame) const override; + virtual nsRect ParentRelativeBounds() override; // HyperLinkAccessible virtual uint32_t StartOffset() override;