diff --git a/accessible/android/AccessibleWrap.cpp b/accessible/android/AccessibleWrap.cpp index 08bb5b5b7d0a..7a1699479738 100644 --- a/accessible/android/AccessibleWrap.cpp +++ b/accessible/android/AccessibleWrap.cpp @@ -660,11 +660,11 @@ mozilla::java::GeckoBundle::LocalRef AccessibleWrap::ToBundle(bool aSmall) { } mozilla::java::GeckoBundle::LocalRef AccessibleWrap::ToBundle( - const uint64_t aState, const nsIntRect& aBounds, const uint8_t aActionCount, - const nsString& aName, const nsString& aTextValue, - const nsString& aDOMNodeID, const nsString& aDescription, - const double& aCurVal, const double& aMinVal, const double& aMaxVal, - const double& aStep, AccAttributes* aAttributes) { + const uint64_t aState, const LayoutDeviceIntRect& aBounds, + const uint8_t aActionCount, const nsString& aName, + const nsString& aTextValue, const nsString& aDOMNodeID, + const nsString& aDescription, const double& aCurVal, const double& aMinVal, + const double& aMaxVal, const double& aStep, AccAttributes* aAttributes) { if (!IsProxy() && IsDefunct()) { return nullptr; } diff --git a/accessible/android/AccessibleWrap.h b/accessible/android/AccessibleWrap.h index f233ee73ec11..fa384f090247 100644 --- a/accessible/android/AccessibleWrap.h +++ b/accessible/android/AccessibleWrap.h @@ -55,7 +55,7 @@ class AccessibleWrap : public LocalAccessible { mozilla::java::GeckoBundle::LocalRef ToBundle(bool aSmall = false); mozilla::java::GeckoBundle::LocalRef ToBundle( - const uint64_t aState, const nsIntRect& aBounds, + const uint64_t aState, const LayoutDeviceIntRect& aBounds, const uint8_t aActionCount, const nsString& aName, const nsString& aTextValue, const nsString& aDOMNodeID, const nsString& aDescription, diff --git a/accessible/android/RemoteAccessibleWrap.cpp b/accessible/android/RemoteAccessibleWrap.cpp index f51818b55008..4c61ffa456b7 100644 --- a/accessible/android/RemoteAccessibleWrap.cpp +++ b/accessible/android/RemoteAccessibleWrap.cpp @@ -74,7 +74,9 @@ void RemoteAccessibleWrap::Value(nsString& aValue) const { uint64_t RemoteAccessibleWrap::State() { return Proxy()->State(); } -nsIntRect RemoteAccessibleWrap::Bounds() const { return Proxy()->Bounds(); } +mozilla::LayoutDeviceIntRect RemoteAccessibleWrap::Bounds() const { + return Proxy()->Bounds(); +} void RemoteAccessibleWrap::ScrollTo(uint32_t aHow) const { Proxy()->ScrollTo(aHow); diff --git a/accessible/android/RemoteAccessibleWrap.h b/accessible/android/RemoteAccessibleWrap.h index 46c3f22853ae..830b2af7f2cf 100644 --- a/accessible/android/RemoteAccessibleWrap.h +++ b/accessible/android/RemoteAccessibleWrap.h @@ -41,7 +41,7 @@ class RemoteAccessibleWrap : public AccessibleWrap { virtual uint64_t State() override; - virtual nsIntRect Bounds() const override; + virtual LayoutDeviceIntRect Bounds() const override; MOZ_CAN_RUN_SCRIPT virtual void ScrollTo(uint32_t aHow) const override; diff --git a/accessible/atk/nsMaiInterfaceComponent.cpp b/accessible/atk/nsMaiInterfaceComponent.cpp index a9b39293ab8d..f3d137d75d10 100644 --- a/accessible/atk/nsMaiInterfaceComponent.cpp +++ b/accessible/atk/nsMaiInterfaceComponent.cpp @@ -105,7 +105,8 @@ AtkObject* refAccessibleAtPointHelper(AtkObject* aAtkObj, gint aX, gint aY, node = browser->GetOwnerElement(); } MOZ_ASSERT(node); - nsIntPoint winCoords = nsCoreUtils::GetScreenCoordsForWindow(node); + mozilla::LayoutDeviceIntPoint winCoords = + nsCoreUtils::GetScreenCoordsForWindow(node); aX += winCoords.x; aY += winCoords.y; } @@ -138,11 +139,11 @@ void getExtentsHelper(AtkObject* aAtkObj, gint* aX, gint* aY, gint* aWidth, return; } - nsIntRect screenRect = accWrap->Bounds(); + mozilla::LayoutDeviceIntRect screenRect = accWrap->Bounds(); if (screenRect.IsEmpty()) return; if (aCoordType == ATK_XY_WINDOW) { - nsIntPoint winCoords = + mozilla::LayoutDeviceIntPoint winCoords = nsCoreUtils::GetScreenCoordsForWindow(accWrap->GetNode()); screenRect.x -= winCoords.x; screenRect.y -= winCoords.y; diff --git a/accessible/atk/nsMaiInterfaceImage.cpp b/accessible/atk/nsMaiInterfaceImage.cpp index 6ec73e57c722..d619340cefc3 100644 --- a/accessible/atk/nsMaiInterfaceImage.cpp +++ b/accessible/atk/nsMaiInterfaceImage.cpp @@ -21,7 +21,7 @@ const gchar* getDescriptionCB(AtkObject* aAtkObj); static void getImagePositionCB(AtkImage* aImage, gint* aAccX, gint* aAccY, AtkCoordType aCoordType) { - nsIntPoint pos = nsIntPoint(-1, -1); + LayoutDeviceIntPoint pos(-1, -1); uint32_t geckoCoordType = (aCoordType == ATK_XY_WINDOW) ? nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE @@ -45,7 +45,7 @@ static const gchar* getImageDescriptionCB(AtkImage* aImage) { static void getImageSizeCB(AtkImage* aImage, gint* aAccWidth, gint* aAccHeight) { - nsIntSize size = nsIntSize(-1, -1); + LayoutDeviceIntSize size(-1, -1); AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage)); if (accWrap && accWrap->IsImage()) { size = accWrap->AsImage()->Size(); diff --git a/accessible/atk/nsMaiInterfaceText.cpp b/accessible/atk/nsMaiInterfaceText.cpp index f98c5a7a13c3..2db21a1154cd 100644 --- a/accessible/atk/nsMaiInterfaceText.cpp +++ b/accessible/atk/nsMaiInterfaceText.cpp @@ -323,7 +323,7 @@ static void getCharacterExtentsCB(AtkText* aText, gint aOffset, gint* aX, } *aX = *aY = *aWidth = *aHeight = -1; - nsIntRect rect; + LayoutDeviceIntRect rect; uint32_t geckoCoordType; if (aCoords == ATK_XY_SCREEN) { geckoCoordType = nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE; @@ -359,7 +359,7 @@ static void getRangeExtentsCB(AtkText* aText, gint aStartOffset, } aRect->x = aRect->y = aRect->width = aRect->height = -1; - nsIntRect rect; + LayoutDeviceIntRect rect; uint32_t geckoCoordType; if (aCoords == ATK_XY_SCREEN) { geckoCoordType = nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE; diff --git a/accessible/base/Pivot.cpp b/accessible/base/Pivot.cpp index 571abbf6cbeb..32516ca48ccf 100644 --- a/accessible/base/Pivot.cpp +++ b/accessible/base/Pivot.cpp @@ -547,8 +547,9 @@ Accessible* Pivot::AtPoint(int32_t aX, int32_t aY, PivotRule& aRule) { // Match if no node below this is a match if ((filtered & nsIAccessibleTraversalRule::FILTER_MATCH) && !match) { - nsIntRect childRect = child->IsLocal() ? child->AsLocal()->Bounds() - : child->AsRemote()->Bounds(); + LayoutDeviceIntRect childRect = child->IsLocal() + ? child->AsLocal()->Bounds() + : child->AsRemote()->Bounds(); // Double-check child's bounds since the deepest child may have been out // of bounds. This assures we don't return a false positive. if (childRect.Contains(aX, aY)) { diff --git a/accessible/base/nsAccUtils.cpp b/accessible/base/nsAccUtils.cpp index d7f4022af2c9..74300e3a00bd 100644 --- a/accessible/base/nsAccUtils.cpp +++ b/accessible/base/nsAccUtils.cpp @@ -244,10 +244,10 @@ HyperTextAccessible* nsAccUtils::GetTextContainer(nsINode* aNode) { return nullptr; } -nsIntPoint nsAccUtils::ConvertToScreenCoords(int32_t aX, int32_t aY, - uint32_t aCoordinateType, - LocalAccessible* aAccessible) { - nsIntPoint coords(aX, aY); +LayoutDeviceIntPoint nsAccUtils::ConvertToScreenCoords( + int32_t aX, int32_t aY, uint32_t aCoordinateType, + LocalAccessible* aAccessible) { + LayoutDeviceIntPoint coords(aX, aY); switch (aCoordinateType) { case nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE: @@ -278,7 +278,7 @@ void nsAccUtils::ConvertScreenCoordsTo(int32_t* aX, int32_t* aY, break; case nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE: { - nsIntPoint coords = + LayoutDeviceIntPoint coords = nsCoreUtils::GetScreenCoordsForWindow(aAccessible->GetNode()); *aX -= coords.x; *aY -= coords.y; @@ -286,7 +286,7 @@ void nsAccUtils::ConvertScreenCoordsTo(int32_t* aX, int32_t* aY, } case nsIAccessibleCoordinateType::COORDTYPE_PARENT_RELATIVE: { - nsIntPoint coords = GetScreenCoordsForParent(aAccessible); + LayoutDeviceIntPoint coords = GetScreenCoordsForParent(aAccessible); *aX -= coords.x; *aY -= coords.y; break; @@ -297,16 +297,18 @@ void nsAccUtils::ConvertScreenCoordsTo(int32_t* aX, int32_t* aY, } } -nsIntPoint nsAccUtils::GetScreenCoordsForParent(LocalAccessible* aAccessible) { +LayoutDeviceIntPoint nsAccUtils::GetScreenCoordsForParent( + LocalAccessible* aAccessible) { LocalAccessible* parent = aAccessible->LocalParent(); - if (!parent) return nsIntPoint(0, 0); + if (!parent) return LayoutDeviceIntPoint(0, 0); nsIFrame* parentFrame = parent->GetFrame(); - if (!parentFrame) return nsIntPoint(0, 0); + if (!parentFrame) return LayoutDeviceIntPoint(0, 0); nsRect rect = parentFrame->GetScreenRectInAppUnits(); - return nsPoint(rect.X(), rect.Y()) - .ToNearestPixels(parentFrame->PresContext()->AppUnitsPerDevPixel()); + nscoord appUnitsRatio = parentFrame->PresContext()->AppUnitsPerDevPixel(); + return LayoutDeviceIntPoint::FromAppUnitsToNearest( + nsPoint(rect.X(), rect.Y()), appUnitsRatio); } bool nsAccUtils::GetLiveAttrValue(uint32_t aRule, nsAString& aValue) { diff --git a/accessible/base/nsAccUtils.h b/accessible/base/nsAccUtils.h index c88d0446307c..6bc85d23a798 100644 --- a/accessible/base/nsAccUtils.h +++ b/accessible/base/nsAccUtils.h @@ -131,24 +131,24 @@ class nsAccUtils { /** * Converts the given coordinates to coordinates relative screen. * - * @param aX [in] the given x coord - * @param aY [in] the given y coord + * @param aX [in] the given x coord in dev pixels + * @param aY [in] the given y coord in dev pixels * @param aCoordinateType [in] specifies coordinates origin (refer to * nsIAccessibleCoordinateType) * @param aAccessible [in] the accessible if coordinates are given * relative it. * @return converted coordinates */ - static nsIntPoint ConvertToScreenCoords(int32_t aX, int32_t aY, - uint32_t aCoordinateType, - LocalAccessible* aAccessible); + static LayoutDeviceIntPoint ConvertToScreenCoords( + int32_t aX, int32_t aY, uint32_t aCoordinateType, + LocalAccessible* aAccessible); /** * Converts the given coordinates relative screen to another coordinate * system. * - * @param aX [in, out] the given x coord - * @param aY [in, out] the given y coord + * @param aX [in, out] the given x coord in dev pixels + * @param aY [in, out] the given y coord in dev pixels * @param aCoordinateType [in] specifies coordinates origin (refer to * nsIAccessibleCoordinateType) * @param aAccessible [in] the accessible if coordinates are given @@ -159,11 +159,13 @@ class nsAccUtils { LocalAccessible* aAccessible); /** - * Returns coordinates relative screen for the parent of the given accessible. + * Returns screen-relative coordinates (in dev pixels) for the parent of the + * given accessible. * * @param [in] aAccessible the accessible */ - static nsIntPoint GetScreenCoordsForParent(LocalAccessible* aAccessible); + static LayoutDeviceIntPoint GetScreenCoordsForParent( + LocalAccessible* aAccessible); /** * Get the 'live' or 'container-live' object attribute value from the given diff --git a/accessible/base/nsCoreUtils.cpp b/accessible/base/nsCoreUtils.cpp index a2da8105bc8a..8b80fe65dd3a 100644 --- a/accessible/base/nsCoreUtils.cpp +++ b/accessible/base/nsCoreUtils.cpp @@ -255,12 +255,12 @@ nsresult nsCoreUtils::ScrollSubstringTo(nsIFrame* aFrame, nsRange* aRange, void nsCoreUtils::ScrollFrameToPoint(nsIFrame* aScrollableFrame, nsIFrame* aFrame, - const nsIntPoint& aPoint) { + const LayoutDeviceIntPoint& aPoint) { nsIScrollableFrame* scrollableFrame = do_QueryFrame(aScrollableFrame); if (!scrollableFrame) return; - nsPoint point = - ToAppUnits(aPoint, aFrame->PresContext()->AppUnitsPerDevPixel()); + nsPoint point = LayoutDeviceIntPoint::ToAppUnits( + aPoint, aFrame->PresContext()->AppUnitsPerDevPixel()); nsRect frameRect = aFrame->GetScreenRectInAppUnits(); nsPoint deltaPoint = point - frameRect.TopLeft(); @@ -322,8 +322,8 @@ void nsCoreUtils::ConvertScrollTypeToPercents(uint32_t aScrollType, *aHorizontal = ScrollAxis(whereX, whenX); } -nsIntPoint nsCoreUtils::GetScreenCoordsForWindow(nsINode* aNode) { - nsIntPoint coords(0, 0); +LayoutDeviceIntPoint nsCoreUtils::GetScreenCoordsForWindow(nsINode* aNode) { + LayoutDeviceIntPoint coords(0, 0); nsCOMPtr treeItem(GetDocShellFor(aNode)); if (!treeItem) return coords; diff --git a/accessible/base/nsCoreUtils.h b/accessible/base/nsCoreUtils.h index 780078cbe645..8f5ed27d6f5d 100644 --- a/accessible/base/nsCoreUtils.h +++ b/accessible/base/nsCoreUtils.h @@ -14,6 +14,7 @@ #include "nsPoint.h" #include "nsTArray.h" +#include "Units.h" class nsRange; class nsTreeColumn; @@ -167,10 +168,10 @@ class nsCoreUtils { * * @param aScrollableFrame the scrollable frame * @param aFrame the frame to scroll - * @param aPoint the point scroll to + * @param aPoint the point scroll to (in dev pixels) */ static void ScrollFrameToPoint(nsIFrame* aScrollableFrame, nsIFrame* aFrame, - const nsIntPoint& aPoint); + const mozilla::LayoutDeviceIntPoint& aPoint); /** * Converts scroll type constant defined in nsIAccessibleScrollType to @@ -186,7 +187,7 @@ class nsCoreUtils { * * @param aNode the DOM node hosted in the window. */ - static nsIntPoint GetScreenCoordsForWindow(nsINode* aNode); + static mozilla::LayoutDeviceIntPoint GetScreenCoordsForWindow(nsINode* aNode); /** * Return document shell for the given DOM node. diff --git a/accessible/basetypes/Accessible.h b/accessible/basetypes/Accessible.h index c1008f06b0d0..0b6955657c09 100644 --- a/accessible/basetypes/Accessible.h +++ b/accessible/basetypes/Accessible.h @@ -10,6 +10,7 @@ #include "mozilla/a11y/AccTypes.h" #include "nsString.h" #include "nsRect.h" +#include "Units.h" class nsAtom; @@ -157,7 +158,10 @@ class Accessible { virtual double MaxValue() const = 0; virtual double Step() const = 0; - virtual nsIntRect Bounds() const = 0; + /** + * Return boundaries in screen coordinates in device pixels. + */ + virtual LayoutDeviceIntRect Bounds() const = 0; /** * Returns text of accessible if accessible has text role otherwise empty diff --git a/accessible/generic/ApplicationAccessible.cpp b/accessible/generic/ApplicationAccessible.cpp index 1503c82a2323..4e4daaddb1a0 100644 --- a/accessible/generic/ApplicationAccessible.cpp +++ b/accessible/generic/ApplicationAccessible.cpp @@ -94,7 +94,9 @@ Relation ApplicationAccessible::RelationByType( return Relation(); } -nsIntRect ApplicationAccessible::Bounds() const { return nsIntRect(); } +mozilla::LayoutDeviceIntRect ApplicationAccessible::Bounds() const { + return mozilla::LayoutDeviceIntRect(); +} nsRect ApplicationAccessible::BoundsInAppUnits() const { return nsRect(); } diff --git a/accessible/generic/ApplicationAccessible.h b/accessible/generic/ApplicationAccessible.h index 3f3c1626cfcb..fdfb52732d1a 100644 --- a/accessible/generic/ApplicationAccessible.h +++ b/accessible/generic/ApplicationAccessible.h @@ -33,7 +33,7 @@ class ApplicationAccessible : public AccessibleWrap { // LocalAccessible virtual void Shutdown() override; - virtual nsIntRect Bounds() const override; + virtual LayoutDeviceIntRect Bounds() const override; virtual nsRect BoundsInAppUnits() const override; virtual already_AddRefed NativeAttributes() override; virtual GroupPos GroupPosition() override; diff --git a/accessible/generic/HyperTextAccessible.cpp b/accessible/generic/HyperTextAccessible.cpp index ea7eaea84533..6453bddae3c7 100644 --- a/accessible/generic/HyperTextAccessible.cpp +++ b/accessible/generic/HyperTextAccessible.cpp @@ -206,22 +206,22 @@ uint64_t HyperTextAccessible::NativeState() const { return states; } -nsIntRect HyperTextAccessible::GetBoundsInFrame(nsIFrame* aFrame, - uint32_t aStartRenderedOffset, - uint32_t aEndRenderedOffset) { +LayoutDeviceIntRect HyperTextAccessible::GetBoundsInFrame( + nsIFrame* aFrame, uint32_t aStartRenderedOffset, + uint32_t aEndRenderedOffset) { nsPresContext* presContext = mDoc->PresContext(); if (!aFrame->IsTextFrame()) { - return aFrame->GetScreenRectInAppUnits().ToNearestPixels( - presContext->AppUnitsPerDevPixel()); + return LayoutDeviceIntRect::FromAppUnitsToNearest( + aFrame->GetScreenRectInAppUnits(), presContext->AppUnitsPerDevPixel()); } // Substring must be entirely within the same text node. int32_t startContentOffset, endContentOffset; nsresult rv = RenderedToContentOffset(aFrame, aStartRenderedOffset, &startContentOffset); - NS_ENSURE_SUCCESS(rv, nsIntRect()); + NS_ENSURE_SUCCESS(rv, LayoutDeviceIntRect()); rv = RenderedToContentOffset(aFrame, aEndRenderedOffset, &endContentOffset); - NS_ENSURE_SUCCESS(rv, nsIntRect()); + NS_ENSURE_SUCCESS(rv, LayoutDeviceIntRect()); nsIFrame* frame; int32_t startContentOffsetInFrame; @@ -229,7 +229,7 @@ nsIntRect HyperTextAccessible::GetBoundsInFrame(nsIFrame* aFrame, // the primary frame passed in rv = aFrame->GetChildFrameContainingOffset( startContentOffset, false, &startContentOffsetInFrame, &frame); - NS_ENSURE_SUCCESS(rv, nsIntRect()); + NS_ENSURE_SUCCESS(rv, LayoutDeviceIntRect()); nsRect screenRect; while (frame && startContentOffset < endContentOffset) { @@ -248,13 +248,13 @@ nsIntRect HyperTextAccessible::GetBoundsInFrame(nsIFrame* aFrame, // Add the point where the string starts to the frameScreenRect nsPoint frameTextStartPoint; rv = frame->GetPointFromOffset(startContentOffset, &frameTextStartPoint); - NS_ENSURE_SUCCESS(rv, nsIntRect()); + NS_ENSURE_SUCCESS(rv, LayoutDeviceIntRect()); // Use the point for the end offset to calculate the width nsPoint frameTextEndPoint; rv = frame->GetPointFromOffset(startContentOffset + frameSubStringLength, &frameTextEndPoint); - NS_ENSURE_SUCCESS(rv, nsIntRect()); + NS_ENSURE_SUCCESS(rv, LayoutDeviceIntRect()); frameScreenRect.SetRectX( frameScreenRect.X() + @@ -269,7 +269,8 @@ nsIntRect HyperTextAccessible::GetBoundsInFrame(nsIFrame* aFrame, frame = frame->GetNextContinuation(); } - return screenRect.ToNearestPixels(presContext->AppUnitsPerDevPixel()); + return LayoutDeviceIntRect::FromAppUnitsToNearest( + screenRect, presContext->AppUnitsPerDevPixel()); } uint32_t HyperTextAccessible::DOMPointToOffset(nsINode* aNode, @@ -1424,12 +1425,12 @@ int32_t HyperTextAccessible::OffsetAtPoint(int32_t aX, int32_t aY, nsIFrame* hyperFrame = GetFrame(); if (!hyperFrame) return -1; - nsIntPoint coords = + LayoutDeviceIntPoint coords = nsAccUtils::ConvertToScreenCoords(aX, aY, aCoordType, this); nsPresContext* presContext = mDoc->PresContext(); - nsPoint coordsInAppUnits = - ToAppUnits(coords, presContext->AppUnitsPerDevPixel()); + nsPoint coordsInAppUnits = LayoutDeviceIntPoint::ToAppUnits( + coords, presContext->AppUnitsPerDevPixel()); nsRect frameScreenRect = hyperFrame->GetScreenRectInAppUnits(); if (!frameScreenRect.Contains(coordsInAppUnits.x, coordsInAppUnits.y)) { @@ -1485,15 +1486,15 @@ int32_t HyperTextAccessible::OffsetAtPoint(int32_t aX, int32_t aY, return -1; // Not found } -nsIntRect HyperTextAccessible::TextBounds(int32_t aStartOffset, - int32_t aEndOffset, - uint32_t aCoordType) { +LayoutDeviceIntRect HyperTextAccessible::TextBounds(int32_t aStartOffset, + int32_t aEndOffset, + uint32_t aCoordType) { index_t startOffset = ConvertMagicOffset(aStartOffset); index_t endOffset = ConvertMagicOffset(aEndOffset); if (!startOffset.IsValid() || !endOffset.IsValid() || startOffset > endOffset || endOffset > CharacterCount()) { NS_ERROR("Wrong in offset"); - return nsIntRect(); + return LayoutDeviceIntRect(); } if (CharacterCount() == 0) { @@ -1501,16 +1502,16 @@ nsIntRect HyperTextAccessible::TextBounds(int32_t aStartOffset, // Empty content, use our own bound to at least get x,y coordinates nsIFrame* frame = GetFrame(); if (!frame) { - return nsIntRect(); + return LayoutDeviceIntRect(); } - return frame->GetScreenRectInAppUnits().ToNearestPixels( - presContext->AppUnitsPerDevPixel()); + return LayoutDeviceIntRect::FromAppUnitsToNearest( + frame->GetScreenRectInAppUnits(), presContext->AppUnitsPerDevPixel()); } int32_t childIdx = GetChildIndexAtOffset(startOffset); - if (childIdx == -1) return nsIntRect(); + if (childIdx == -1) return LayoutDeviceIntRect(); - nsIntRect bounds; + LayoutDeviceIntRect bounds; int32_t prevOffset = GetChildOffset(childIdx); int32_t offset1 = startOffset - prevOffset; @@ -1540,8 +1541,9 @@ nsIntRect HyperTextAccessible::TextBounds(int32_t aStartOffset, // screen coordinates. nsPresContext* presContext = mDoc->PresContext(); nsIFrame* rootFrame = presContext->PresShell()->GetRootFrame(); - nsIntRect orgRectPixels = - rootFrame->GetScreenRectInAppUnits().ToNearestPixels( + LayoutDeviceIntRect orgRectPixels = + LayoutDeviceIntRect::FromAppUnitsToNearest( + rootFrame->GetScreenRectInAppUnits(), presContext->AppUnitsPerDevPixel()); bounds.MoveBy(-orgRectPixels.X(), -orgRectPixels.Y()); bounds.ScaleRoundOut(presContext->PresShell()->GetResolution()); @@ -1803,7 +1805,7 @@ LayoutDeviceIntRect HyperTextAccessible::GetCaretRect(nsIWidget** aWidget) { // focus. return LayoutDeviceIntRect(); } - nsIntRect charRect = CharBounds( + LayoutDeviceIntRect charRect = CharBounds( caretOffset, nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE); if (!charRect.IsEmpty()) { caretRect.SetTopEdge(charRect.Y()); @@ -1945,7 +1947,7 @@ void HyperTextAccessible::ScrollSubstringToPoint(int32_t aStartOffset, nsIFrame* frame = GetFrame(); if (!frame) return; - nsIntPoint coords = + LayoutDeviceIntPoint coords = nsAccUtils::ConvertToScreenCoords(aX, aY, aCoordinateType, this); RefPtr domRange = nsRange::Create(mContent); @@ -1955,8 +1957,8 @@ void HyperTextAccessible::ScrollSubstringToPoint(int32_t aStartOffset, } nsPresContext* presContext = frame->PresContext(); - nsPoint coordsInAppUnits = - ToAppUnits(coords, presContext->AppUnitsPerDevPixel()); + nsPoint coordsInAppUnits = LayoutDeviceIntPoint::ToAppUnits( + coords, presContext->AppUnitsPerDevPixel()); bool initialScrolled = false; nsIFrame* parentFrame = frame; diff --git a/accessible/generic/HyperTextAccessible.h b/accessible/generic/HyperTextAccessible.h index 9dfdbbdfc996..1ca95e387096 100644 --- a/accessible/generic/HyperTextAccessible.h +++ b/accessible/generic/HyperTextAccessible.h @@ -184,18 +184,19 @@ class HyperTextAccessible : public AccessibleWrap, int32_t OffsetAtPoint(int32_t aX, int32_t aY, uint32_t aCoordType); /** - * Return a rect of the given text range relative given coordinate system. + * Return a rect (in dev pixels) of the given text range relative given + * coordinate system. */ - nsIntRect TextBounds( + LayoutDeviceIntRect TextBounds( int32_t aStartOffset, int32_t aEndOffset, uint32_t aCoordType = nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE); /** - * Return a rect for character at given offset relative given coordinate - * system. + * Return a rect (in dev pixels) for character at given offset relative given + * coordinate system. */ - nsIntRect CharBounds(int32_t aOffset, uint32_t aCoordType) { + LayoutDeviceIntRect CharBounds(int32_t aOffset, uint32_t aCoordType) { int32_t endOffset = aOffset == static_cast(CharacterCount()) ? aOffset : aOffset + 1; @@ -394,11 +395,13 @@ class HyperTextAccessible : public AccessibleWrap, EWordMovementType aWordMovementType = eDefaultBehavior); /** - * Return the boundaries of the substring in case of textual frame or - * frame boundaries in case of non textual frame, offsets are ignored. + * Return the boundaries (in dev pixels) of the substring in case of textual + * frame or frame boundaries in case of non textual frame, offsets are + * ignored. */ - nsIntRect GetBoundsInFrame(nsIFrame* aFrame, uint32_t aStartRenderedOffset, - uint32_t aEndRenderedOffset); + LayoutDeviceIntRect GetBoundsInFrame(nsIFrame* aFrame, + uint32_t aStartRenderedOffset, + uint32_t aEndRenderedOffset); // Selection helpers diff --git a/accessible/generic/ImageAccessible.cpp b/accessible/generic/ImageAccessible.cpp index ef76e3841400..ade657f22289 100644 --- a/accessible/generic/ImageAccessible.cpp +++ b/accessible/generic/ImageAccessible.cpp @@ -23,7 +23,7 @@ #include "nsPIDOMWindow.h" #include "nsIURI.h" -using namespace mozilla::a11y; +namespace mozilla::a11y { NS_IMPL_ISUPPORTS_INHERITED(ImageAccessible, LinkableAccessible, imgINotificationObserver) @@ -137,7 +137,7 @@ bool ImageAccessible::DoAction(uint8_t aIndex) const { nsCOMPtr piWindow = document->GetWindow(); if (!piWindow) return false; - RefPtr tmp; + RefPtr tmp; return NS_SUCCEEDED(piWindow->Open(spec, u""_ns, u""_ns, /* aLoadInfo = */ nullptr, /* aForceNoOpener = */ false, @@ -147,13 +147,13 @@ bool ImageAccessible::DoAction(uint8_t aIndex) const { //////////////////////////////////////////////////////////////////////////////// // ImageAccessible -nsIntPoint ImageAccessible::Position(uint32_t aCoordType) { - nsIntPoint point = Bounds().TopLeft(); +LayoutDeviceIntPoint ImageAccessible::Position(uint32_t aCoordType) { + LayoutDeviceIntPoint point = Bounds().TopLeft(); nsAccUtils::ConvertScreenCoordsTo(&point.x, &point.y, aCoordType, this); return point; } -nsIntSize ImageAccessible::Size() { return Bounds().Size(); } +LayoutDeviceIntSize ImageAccessible::Size() { return Bounds().Size(); } // LocalAccessible already_AddRefed ImageAccessible::NativeAttributes() { @@ -247,3 +247,5 @@ void ImageAccessible::Notify(imgIRequest* aRequest, int32_t aType, mImageRequestStatus = status; } + +} // namespace mozilla::a11y diff --git a/accessible/generic/ImageAccessible.h b/accessible/generic/ImageAccessible.h index 679589d259fa..a907320d9427 100644 --- a/accessible/generic/ImageAccessible.h +++ b/accessible/generic/ImageAccessible.h @@ -37,8 +37,8 @@ class ImageAccessible : public LinkableAccessible, virtual bool DoAction(uint8_t aIndex) const override; // ImageAccessible - nsIntPoint Position(uint32_t aCoordType); - nsIntSize Size(); + LayoutDeviceIntPoint Position(uint32_t aCoordType); + LayoutDeviceIntSize Size(); protected: virtual ~ImageAccessible(); diff --git a/accessible/generic/LocalAccessible.cpp b/accessible/generic/LocalAccessible.cpp index 7ef6801d57d2..36ce500b2f44 100644 --- a/accessible/generic/LocalAccessible.cpp +++ b/accessible/generic/LocalAccessible.cpp @@ -501,7 +501,7 @@ LocalAccessible* LocalAccessible::LocalChildAtPoint( // If we can't find the point in a child, we will return the fallback answer: // we return |this| if the point is within it, otherwise nullptr. LocalAccessible* fallbackAnswer = nullptr; - nsIntRect rect = Bounds(); + LayoutDeviceIntRect rect = Bounds(); if (rect.Contains(aX, aY)) fallbackAnswer = this; if (nsAccUtils::MustPrune(this)) { // Do not dig any further @@ -611,7 +611,7 @@ LocalAccessible* LocalAccessible::LocalChildAtPoint( for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) { LocalAccessible* child = accessible->LocalChildAt(childIdx); - nsIntRect childRect = child->Bounds(); + LayoutDeviceIntRect childRect = child->Bounds(); if (childRect.Contains(aX, aY) && (child->State() & states::INVISIBLE) == 0) { if (aWhichChild == EWhichChildAtPoint::DeepestChild) { @@ -786,9 +786,9 @@ nsRect LocalAccessible::BoundsInAppUnits() const { return unionRectTwips; } -nsIntRect LocalAccessible::Bounds() const { - return BoundsInAppUnits().ToNearestPixels( - mDoc->PresContext()->AppUnitsPerDevPixel()); +LayoutDeviceIntRect LocalAccessible::Bounds() const { + return LayoutDeviceIntRect::FromAppUnitsToNearest( + BoundsInAppUnits(), mDoc->PresContext()->AppUnitsPerDevPixel()); } nsIntRect LocalAccessible::BoundsInCSSPixels() const { @@ -2296,7 +2296,7 @@ void LocalAccessible::ScrollToPoint(uint32_t aCoordinateType, int32_t aX, nsIFrame* frame = GetFrame(); if (!frame) return; - nsIntPoint coords = + LayoutDeviceIntPoint coords = nsAccUtils::ConvertToScreenCoords(aX, aY, aCoordinateType, this); nsIFrame* parentFrame = frame; diff --git a/accessible/generic/LocalAccessible.h b/accessible/generic/LocalAccessible.h index 0d6dc84b63e8..1ed2406c3525 100644 --- a/accessible/generic/LocalAccessible.h +++ b/accessible/generic/LocalAccessible.h @@ -406,10 +406,7 @@ class LocalAccessible : public nsISupports, public Accessible { */ virtual nsRect BoundsInAppUnits() const; - /** - * Return boundaries in screen coordinates. - */ - virtual nsIntRect Bounds() const override; + virtual LayoutDeviceIntRect Bounds() const override; /** * Return boundaries in screen coordinates in CSS pixels. diff --git a/accessible/generic/OuterDocAccessible.cpp b/accessible/generic/OuterDocAccessible.cpp index e5320ce0ee87..3c03551e980e 100644 --- a/accessible/generic/OuterDocAccessible.cpp +++ b/accessible/generic/OuterDocAccessible.cpp @@ -77,7 +77,7 @@ role OuterDocAccessible::NativeRole() const { return roles::INTERNAL_FRAME; } LocalAccessible* OuterDocAccessible::LocalChildAtPoint( int32_t aX, int32_t aY, EWhichChildAtPoint aWhichChild) { - nsIntRect docRect = Bounds(); + LayoutDeviceIntRect docRect = Bounds(); if (!docRect.Contains(aX, aY)) return nullptr; // Always return the inner doc as direct child accessible unless bounds @@ -212,7 +212,7 @@ Accessible* OuterDocAccessible::ChildAt(uint32_t aIndex) const { Accessible* OuterDocAccessible::ChildAtPoint(int32_t aX, int32_t aY, EWhichChildAtPoint aWhichChild) { - nsIntRect docRect = Bounds(); + LayoutDeviceIntRect docRect = Bounds(); if (!docRect.Contains(aX, aY)) return nullptr; // Always return the inner doc as direct child accessible unless bounds diff --git a/accessible/html/HTMLSelectAccessible.cpp b/accessible/html/HTMLSelectAccessible.cpp index 9e142f9959e0..e7c68831a500 100644 --- a/accessible/html/HTMLSelectAccessible.cpp +++ b/accessible/html/HTMLSelectAccessible.cpp @@ -194,8 +194,8 @@ uint64_t HTMLSelectOptionAccessible::NativeState() const { //