Bug 1732154: Add ParentRelativeBounds method for HTMLImageMapAccessible r=eeejay

Differential Revision: https://phabricator.services.mozilla.com/D126386
This commit is contained in:
Morgan Reschenberg 2021-10-04 19:46:55 +00:00
Родитель c2cac47ff1
Коммит 2162cc6e2d
2 изменённых файлов: 25 добавлений и 0 удалений

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;