Bug 1423541: Use BaseRect access methods instead of member variables in accessible/ r=surkov

MozReview-Commit-ID: KRfgYEW7aWY

--HG--
extra : rebase_source : b88fcdb3095ac9bfa82ae6a596070d80c1c482fd
This commit is contained in:
Milan Sreckovic 2018-01-12 12:07:29 -05:00
parent b600182b11
commit 6cf51345e7
21 changed files with 76 additions and 88 deletions

View File

@ -368,7 +368,7 @@ nsAccUtils::GetScreenCoordsForParent(Accessible* aAccessible)
return nsIntPoint(0, 0);
nsRect rect = parentFrame->GetScreenRectInAppUnits();
return nsPoint(rect.x, rect.y).
return nsPoint(rect.X(), rect.Y()).
ToNearestPixels(parentFrame->PresContext()->AppUnitsPerDevPixel());
}

View File

@ -586,8 +586,7 @@ nsAccessiblePivot::MoveToPoint(nsIAccessibleTraversalRule* aRule,
nsIntRect childRect = child->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 (aX >= childRect.x && aX < childRect.x + childRect.width &&
aY >= childRect.y && aY < childRect.y + childRect.height)
if (childRect.Contains(aX, aY))
match = child;
}

View File

@ -302,7 +302,7 @@ nsCoreUtils::ScrollFrameToPoint(nsIFrame *aScrollableFrame,
nsPoint point =
ToAppUnits(aPoint, aFrame->PresContext()->AppUnitsPerDevPixel());
nsRect frameRect = aFrame->GetScreenRectInAppUnits();
nsPoint deltaPoint(point.x - frameRect.x, point.y - frameRect.y);
nsPoint deltaPoint = point - frameRect.TopLeft();
nsPoint scrollPoint = scrollableFrame->GetScrollPosition();
scrollPoint -= deltaPoint;

View File

@ -514,8 +514,7 @@ Accessible::ChildAtPoint(int32_t aX, int32_t aY,
// we return |this| if the point is within it, otherwise nullptr.
Accessible* fallbackAnswer = nullptr;
nsIntRect rect = Bounds();
if (aX >= rect.x && aX < rect.x + rect.width &&
aY >= rect.y && aY < rect.y + rect.height)
if (rect.Contains(aX, aY))
fallbackAnswer = this;
if (nsAccUtils::MustPrune(this)) // Do not dig any further
@ -543,7 +542,7 @@ Accessible::ChildAtPoint(int32_t aX, int32_t aY,
WidgetMouseEvent dummyEvent(true, eMouseMove, rootWidget,
WidgetMouseEvent::eSynthesized);
dummyEvent.mRefPoint = LayoutDeviceIntPoint(aX - rootRect.x, aY - rootRect.y);
dummyEvent.mRefPoint = LayoutDeviceIntPoint(aX - rootRect.X(), aY - rootRect.Y());
nsIFrame* popupFrame = nsLayoutUtils::
GetPopupFrameForEventCoordinates(accDocument->PresContext()->GetRootPresContext(),
@ -565,8 +564,8 @@ Accessible::ChildAtPoint(int32_t aX, int32_t aY,
nsPresContext* presContext = startFrame->PresContext();
nsRect screenRect = startFrame->GetScreenRectInAppUnits();
nsPoint offset(presContext->DevPixelsToAppUnits(aX) - screenRect.x,
presContext->DevPixelsToAppUnits(aY) - screenRect.y);
nsPoint offset(presContext->DevPixelsToAppUnits(aX) - screenRect.X(),
presContext->DevPixelsToAppUnits(aY) - screenRect.Y());
nsIFrame* foundFrame = nsLayoutUtils::GetFrameForPoint(startFrame, offset);
nsIContent* content = nullptr;
@ -617,8 +616,7 @@ Accessible::ChildAtPoint(int32_t aX, int32_t aY,
Accessible* child = accessible->GetChildAt(childIdx);
nsIntRect childRect = child->Bounds();
if (aX >= childRect.x && aX < childRect.x + childRect.width &&
aY >= childRect.y && aY < childRect.y + childRect.height &&
if (childRect.Contains(aX, aY) &&
(child->State() & states::INVISIBLE) == 0) {
if (aWhichChild == eDeepestChild)
@ -681,17 +679,16 @@ Accessible::Bounds() const
nsIntRect screenRect;
nsPresContext* presContext = mDoc->PresContext();
screenRect.x = presContext->AppUnitsToDevPixels(unionRectTwips.x);
screenRect.y = presContext->AppUnitsToDevPixels(unionRectTwips.y);
screenRect.width = presContext->AppUnitsToDevPixels(unionRectTwips.width);
screenRect.height = presContext->AppUnitsToDevPixels(unionRectTwips.height);
screenRect.SetRect(presContext->AppUnitsToDevPixels(unionRectTwips.X()),
presContext->AppUnitsToDevPixels(unionRectTwips.Y()),
presContext->AppUnitsToDevPixels(unionRectTwips.Width()),
presContext->AppUnitsToDevPixels(unionRectTwips.Height()));
// We have the union of the rectangle, now we need to put it in absolute
// screen coords.
nsIntRect orgRectPixels = boundingFrame->GetScreenRectInAppUnits().
ToNearestPixels(presContext->AppUnitsPerDevPixel());
screenRect.x += orgRectPixels.x;
screenRect.y += orgRectPixels.y;
screenRect.MoveBy(orgRectPixels.X(), orgRectPixels.Y());
return screenRect;
}

View File

@ -141,8 +141,8 @@ HyperTextAccessible::GetBoundsInFrame(nsIFrame* aFrame,
rv = frame->GetPointFromOffset(startContentOffset + frameSubStringLength, &frameTextEndPoint);
NS_ENSURE_SUCCESS(rv, nsIntRect());
frameScreenRect.x += std::min(frameTextStartPoint.x, frameTextEndPoint.x);
frameScreenRect.width = mozilla::Abs(frameTextStartPoint.x - frameTextEndPoint.x);
frameScreenRect.SetRectX(frameScreenRect.X() + std::min(frameTextStartPoint.x, frameTextEndPoint.x),
mozilla::Abs(frameTextStartPoint.x - frameTextEndPoint.x));
screenRect.UnionRect(frameScreenRect, screenRect);
@ -1177,8 +1177,8 @@ HyperTextAccessible::OffsetAtPoint(int32_t aX, int32_t aY, uint32_t aCoordType)
if (!frameScreenRect.Contains(coordsInAppUnits.x, coordsInAppUnits.y))
return -1; // Not found
nsPoint pointInHyperText(coordsInAppUnits.x - frameScreenRect.x,
coordsInAppUnits.y - frameScreenRect.y);
nsPoint pointInHyperText(coordsInAppUnits.x - frameScreenRect.X(),
coordsInAppUnits.y - frameScreenRect.Y());
// Go through the frames to check if each one has the point.
// When one does, add up the character offsets until we have a match
@ -1267,7 +1267,10 @@ HyperTextAccessible::TextBounds(int32_t aStartOffset, int32_t aEndOffset,
offset1 = 0;
}
nsAccUtils::ConvertScreenCoordsTo(&bounds.x, &bounds.y, aCoordType, this);
auto boundsX = bounds.X();
auto boundsY = bounds.Y();
nsAccUtils::ConvertScreenCoordsTo(&boundsX, &boundsY, aCoordType, this);
bounds.MoveTo(boundsX, boundsY);
return bounds;
}
@ -1522,8 +1525,7 @@ HyperTextAccessible::GetCaretRect(nsIWidget** aWidget)
nsIntRect charRect = CharBounds(CaretOffset(),
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE);
if (!charRect.IsEmpty()) {
caretRect.height -= charRect.y - caretRect.y;
caretRect.y = charRect.y;
caretRect.SetTopEdge(charRect.Y());
}
return caretRect;
}
@ -1714,8 +1716,8 @@ HyperTextAccessible::ScrollSubstringToPoint(int32_t aStartOffset,
// Scroll substring to the given point. Turn the point into percents
// relative scrollable area to use nsCoreUtils::ScrollSubstringTo.
nsRect frameRect = parentFrame->GetScreenRectInAppUnits();
nscoord offsetPointX = coordsInAppUnits.x - frameRect.x;
nscoord offsetPointY = coordsInAppUnits.y - frameRect.y;
nscoord offsetPointX = coordsInAppUnits.x - frameRect.X();
nscoord offsetPointY = coordsInAppUnits.y - frameRect.Y();
nsSize size(parentFrame->GetSize());

View File

@ -148,9 +148,9 @@ ImageAccessible::DoAction(uint8_t aIndex)
nsIntPoint
ImageAccessible::Position(uint32_t aCoordType)
{
nsIntRect rect = Bounds();
nsAccUtils::ConvertScreenCoordsTo(&rect.x, &rect.y, aCoordType, this);
return rect.TopLeft();
nsIntPoint point = Bounds().TopLeft();
nsAccUtils::ConvertScreenCoordsTo(&point.x, &point.y, aCoordType, this);
return point;
}
nsIntSize

View File

@ -70,8 +70,7 @@ OuterDocAccessible::ChildAtPoint(int32_t aX, int32_t aY,
EWhichChildAtPoint aWhichChild)
{
nsIntRect docRect = Bounds();
if (aX < docRect.x || aX >= docRect.x + docRect.width ||
aY < docRect.y || aY >= docRect.y + docRect.height)
if (!docRect.Contains(aX, aY))
return nullptr;
// Always return the inner doc as direct child accessible unless bounds

View File

@ -222,7 +222,6 @@ HTMLAreaAccessible::RelativeBounds(nsIFrame** aBoundingFrame) const
// XXX Areas are screwy; they return their rects as a pair of points, one pair
// stored into the width and height.
*aBoundingFrame = frame;
bounds.width -= bounds.x;
bounds.height -= bounds.y;
bounds.SizeTo(bounds.Width() - bounds.X(), bounds.Height() - bounds.Y());
return bounds;
}

View File

@ -87,8 +87,8 @@ HTMLLIAccessible::Bounds() const
nsIntRect bulletRect = mBullet->Bounds();
rect.width += rect.x - bulletRect.x;
rect.x = bulletRect.x; // Move x coordinate of list item over to cover bullet as well
// Move x coordinate of list item over to cover bullet as well
rect.SetLeftEdge(bulletRect.X());
return rect;
}

View File

@ -213,8 +213,8 @@ HTMLSelectOptionAccessible::NativeState()
if (listAcc) {
nsIntRect optionRect = Bounds();
nsIntRect listRect = listAcc->Bounds();
if (optionRect.y < listRect.y ||
optionRect.y + optionRect.height > listRect.y + listRect.height) {
if (optionRect.Y() < listRect.Y() ||
optionRect.YMost() > listRect.YMost()) {
state |= states::OFFSCREEN;
}
}

View File

@ -623,8 +623,8 @@ DocAccessibleParent::MaybeInitWindowEmulation()
if (Compatibility::IsDolphin()) {
rect = Bounds();
nsIntRect rootRect = rootDocument->Bounds();
rect.x = rootRect.x - rect.x;
rect.y -= rootRect.y;
rect.MoveToX(rootRect.X() - rect.X());
rect.MoveToY(rect.Y() - rootRect.Y());
auto tab = static_cast<dom::TabParent*>(Manager());
tab->GetDocShellIsActive(&isActive);
@ -652,8 +652,8 @@ DocAccessibleParent::MaybeInitWindowEmulation()
HWND parentWnd = reinterpret_cast<HWND>(rootDocument->GetNativeWindow());
DebugOnly<HWND> hWnd = nsWinUtils::CreateNativeWindow(kClassNameTabContent,
parentWnd,
rect.x, rect.y,
rect.width, rect.height,
rect.X(), rect.Y(),
rect.Width(), rect.Height(),
isActive, &onCreate);
MOZ_ASSERT(hWnd);
}

View File

@ -231,10 +231,7 @@ ProxyAccessible::Bounds()
if (FAILED(hr)) {
return rect;
}
rect.x = left;
rect.y = top;
rect.width = width;
rect.height = height;
rect.SetRect(left, top, width, height);
return rect;
}

View File

@ -62,16 +62,16 @@ ia2AccessibleComponent::get_locationInParent(long* aX, long* aY)
// parent or relative to the screen on which this object is rendered if it
// has no parent.
if (!acc->Parent()) {
*aX = rect.x;
*aY = rect.y;
*aX = rect.X();
*aY = rect.Y();
return S_OK;
}
// The coordinates of the bounding box are given relative to the parent's
// coordinate system.
nsIntRect parentRect = acc->Parent()->Bounds();
*aX = rect.x - parentRect.x;
*aY = rect.y - parentRect.y;
*aX = rect.X() - parentRect.X();
*aY = rect.Y() - parentRect.Y();
return S_OK;
}

View File

@ -110,10 +110,11 @@ ia2AccessibleText::get_characterExtents(long aOffset,
rect = textAcc->CharBounds(aOffset, geckoCoordType);
*aX = rect.x;
*aY = rect.y;
*aWidth = rect.width;
*aHeight = rect.height;
// Can't use GetRect() because of long vs. int32_t mismatch
*aX = rect.X();
*aY = rect.Y();
*aWidth = rect.Width();
*aHeight = rect.Height();
return S_OK;
}

View File

@ -902,10 +902,10 @@ AccessibleWrap::accLocation(
nsIntRect rect = Bounds();
*pxLeft = rect.x;
*pyTop = rect.y;
*pcxWidth = rect.width;
*pcyHeight = rect.height;
*pxLeft = rect.X();
*pyTop = rect.Y();
*pcxWidth = rect.Width();
*pcyHeight = rect.Height();
return S_OK;
}
@ -1661,12 +1661,12 @@ AccessibleWrap::UpdateSystemCaretFor(HWND aCaretWnd,
// Create invisible bitmap for caret, otherwise its appearance interferes
// with Gecko caret
nsAutoBitmap caretBitMap(CreateBitmap(1, aCaretRect.height, 1, 1, nullptr));
if (::CreateCaret(aCaretWnd, caretBitMap, 1, aCaretRect.height)) { // Also destroys the last caret
nsAutoBitmap caretBitMap(CreateBitmap(1, aCaretRect.Height(), 1, 1, nullptr));
if (::CreateCaret(aCaretWnd, caretBitMap, 1, aCaretRect.Height())) { // Also destroys the last caret
::ShowCaret(aCaretWnd);
RECT windowRect;
::GetWindowRect(aCaretWnd, &windowRect);
::SetCaretPos(aCaretRect.x - windowRect.left, aCaretRect.y - windowRect.top);
::SetCaretPos(aCaretRect.X() - windowRect.left, aCaretRect.Y() - windowRect.top);
}
}

View File

@ -154,8 +154,8 @@ DocAccessibleWrap::DoInitialUpdate()
if (Compatibility::IsDolphin()) {
rect = Bounds();
nsIntRect rootRect = rootDocument->Bounds();
rect.x = rootRect.x - rect.x;
rect.y -= rootRect.y;
rect.MoveToX(rootRect.X() - rect.X());
rect.MoveByY(-rootRect.Y());
nsCOMPtr<nsISupports> container = mDocumentNode->GetContainer();
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(container);
@ -169,8 +169,8 @@ DocAccessibleWrap::DoInitialUpdate()
HWND parentWnd = reinterpret_cast<HWND>(rootDocument->GetNativeWindow());
mHWND = nsWinUtils::CreateNativeWindow(kClassNameTabContent, parentWnd,
rect.x, rect.y,
rect.width, rect.height, isActive,
rect.X(), rect.Y(),
rect.Width(), rect.Height(), isActive,
&onCreate);
} else {
DocAccessible* parentDocument = ParentDocument();

View File

@ -75,10 +75,10 @@ sdnTextAccessible::get_clippedSubstringBounds(unsigned int aStartIndex,
nsIntRect clippedRect;
clippedRect.IntersectRect(unclippedRect, docRect);
*aX = clippedRect.x;
*aY = clippedRect.y;
*aWidth = clippedRect.width;
*aHeight = clippedRect.height;
*aX = clippedRect.X();
*aY = clippedRect.Y();
*aWidth = clippedRect.Width();
*aHeight = clippedRect.Height();
return S_OK;
}
@ -112,17 +112,17 @@ sdnTextAccessible::get_unclippedSubstringBounds(unsigned int aStartIndex,
for (; iter != stopLoopFrame; iter = iter->GetNextContinuation()) {
nsRect rect = iter->GetScreenRectInAppUnits();
nscoord start = (iter == startFrame) ? startPoint.x : 0;
nscoord end = (iter == endFrame) ? endPoint.x : rect.width;
rect.x += start;
rect.width = end - start;
nscoord end = (iter == endFrame) ? endPoint.x : rect.Width();
rect.MoveByX(start);
rect.SetWidth(end - start);
sum.UnionRect(sum, rect);
}
nsPresContext* presContext = mAccessible->Document()->PresContext();
*aX = presContext->AppUnitsToDevPixels(sum.x);
*aY = presContext->AppUnitsToDevPixels(sum.y);
*aWidth = presContext->AppUnitsToDevPixels(sum.width);
*aHeight = presContext->AppUnitsToDevPixels(sum.height);
*aX = presContext->AppUnitsToDevPixels(sum.X());
*aY = presContext->AppUnitsToDevPixels(sum.Y());
*aWidth = presContext->AppUnitsToDevPixels(sum.Width());
*aHeight = presContext->AppUnitsToDevPixels(sum.Height());
return S_OK;
}

View File

@ -452,11 +452,7 @@ xpcAccessible::GetBounds(int32_t* aX, int32_t* aY,
rect = IntlGeneric().AsProxy()->Bounds();
}
*aX = rect.x;
*aY = rect.y;
*aWidth = rect.width;
*aHeight = rect.height;
rect.GetRect(aX, aY, aWidth, aHeight);
return NS_OK;
}

View File

@ -270,8 +270,7 @@ xpcAccessibleHyperText::GetCharacterExtents(int32_t aOffset,
rect = mIntl.AsProxy()->CharBounds(aOffset, aCoordType);
#endif
}
*aX = rect.x; *aY = rect.y;
*aWidth = rect.width; *aHeight = rect.height;
rect.GetRect(aX, aY, aWidth, aHeight);
return NS_OK;
}
@ -300,8 +299,7 @@ xpcAccessibleHyperText::GetRangeExtents(int32_t aStartOffset, int32_t aEndOffset
rect = mIntl.AsProxy()->TextBounds(aStartOffset, aEndOffset, aCoordType);
#endif
}
*aX = rect.x; *aY = rect.y;
*aWidth = rect.width; *aHeight = rect.height;
rect.GetRect(aX, aY, aWidth, aHeight);
return NS_OK;
}

View File

@ -193,8 +193,8 @@ XULTreeAccessible::ChildAtPoint(int32_t aX, int32_t aY,
CSSIntRect rootRect = rootFrame->GetScreenRect();
int32_t clientX = presContext->DevPixelsToIntCSSPixels(aX) - rootRect.x;
int32_t clientY = presContext->DevPixelsToIntCSSPixels(aY) - rootRect.y;
int32_t clientX = presContext->DevPixelsToIntCSSPixels(aX) - rootRect.X();
int32_t clientY = presContext->DevPixelsToIntCSSPixels(aY) - rootRect.Y();
int32_t row = -1;
nsCOMPtr<nsITreeColumn> column;

View File

@ -327,8 +327,8 @@ XULTreeGridRowAccessible::ChildAtPoint(int32_t aX, int32_t aY,
CSSIntRect rootRect = rootFrame->GetScreenRect();
int32_t clientX = presContext->DevPixelsToIntCSSPixels(aX) - rootRect.x;
int32_t clientY = presContext->DevPixelsToIntCSSPixels(aY) - rootRect.y;
int32_t clientX = presContext->DevPixelsToIntCSSPixels(aX) - rootRect.X();
int32_t clientY = presContext->DevPixelsToIntCSSPixels(aY) - rootRect.Y();
int32_t row = -1;
nsCOMPtr<nsITreeColumn> column;