Skip to content

Commit

Permalink
Backed out 3 changesets (bug 1828295) for causing failures on browser…
Browse files Browse the repository at this point in the history
…_caret_rect.js. CLOSED TREE

Backed out changeset 52b9bf7e6344 (bug 1828295)
Backed out changeset 6e6ee5fe337f (bug 1828295)
Backed out changeset 4e8ff9c439ef (bug 1828295)
  • Loading branch information
ncsoregi committed May 31, 2023
1 parent c342e57 commit 6f5c0c5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 205 deletions.
36 changes: 14 additions & 22 deletions accessible/generic/HyperTextAccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include "nsIInterfaceRequestorUtils.h"
#include "nsIScrollableFrame.h"
#include "nsIMathMLFrame.h"
#include "nsLayoutUtils.h"
#include "nsRange.h"
#include "nsTextFragment.h"
#include "mozilla/Assertions.h"
Expand Down Expand Up @@ -732,25 +731,20 @@ LayoutDeviceIntRect HyperTextAccessible::GetCaretRect(nsIWidget** aWidget) {
nsIFrame* frame = caret->GetGeometry(&rect);
if (!frame || rect.IsEmpty()) return LayoutDeviceIntRect();

PresShell* presShell = mDoc->PresShellPtr();
// Transform rect to be relative to the root frame.
nsIFrame* rootFrame = presShell->GetRootFrame();
rect = nsLayoutUtils::TransformFrameRectToAncestor(frame, rect, rootFrame);
// We need to inverse translate with the offset of the edge of the visual
// viewport from top edge of the layout viewport.
nsPoint viewportOffset = presShell->GetVisualViewportOffset() -
presShell->GetLayoutViewportOffset();
rect.MoveBy(-viewportOffset);
// We need to take into account a non-1 resolution set on the presshell.
// This happens with async pinch zooming. Here we scale the bounds before
// adding the screen-relative offset.
rect.ScaleRoundOut(presShell->GetResolution());
// Now we need to put the rect in absolute screen coords.
nsRect rootScreenRect = rootFrame->GetScreenRectInAppUnits();
rect.MoveBy(rootScreenRect.TopLeft());
// Finally, convert from app units.
auto caretRect = LayoutDeviceIntRect::FromAppUnitsToNearest(
rect, presShell->GetPresContext()->AppUnitsPerDevPixel());
nsPoint offset;
// Offset from widget origin to the frame origin, which includes chrome
// on the widget.
*aWidget = frame->GetNearestWidget(offset);
NS_ENSURE_TRUE(*aWidget, LayoutDeviceIntRect());
rect.MoveBy(offset);

LayoutDeviceIntRect caretRect = LayoutDeviceIntRect::FromUnknownRect(
rect.ToOutsidePixels(frame->PresContext()->AppUnitsPerDevPixel()));
// clang-format off
// ((content screen origin) - (content offset in the widget)) = widget origin on the screen
// clang-format on
caretRect.MoveBy((*aWidget)->WidgetToScreenOffset() -
(*aWidget)->GetClientOffset());

// Correct for character size, so that caret always matches the size of
// the character. This is important for font size transitions, and is
Expand All @@ -769,8 +763,6 @@ LayoutDeviceIntRect HyperTextAccessible::GetCaretRect(nsIWidget** aWidget) {
if (!charRect.IsEmpty()) {
caretRect.SetTopEdge(charRect.Y());
}

*aWidget = frame->GetNearestWidget();
return caretRect;
}

Expand Down
2 changes: 0 additions & 2 deletions accessible/interfaces/nsIAccessibleText.idl
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ interface nsIAccessibleText : nsISupports
*/
attribute long caretOffset;

void getCaretRect(out long x, out long y, out long width, out long height);

readonly attribute long characterCount;
readonly attribute long selectionCount;

Expand Down
1 change: 0 additions & 1 deletion accessible/tests/browser/bounds/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ prefs =
javascript.options.asyncstack_capture_debuggee_only=false

[browser_accessible_moved.js]
[browser_caret_rect.js]
[browser_position.js]
[browser_test_resolution.js]
skip-if = os == 'win' # bug 1372296
Expand Down
155 changes: 0 additions & 155 deletions accessible/tests/browser/bounds/browser_caret_rect.js

This file was deleted.

7 changes: 4 additions & 3 deletions accessible/windows/msaa/AccessibleWrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ void AccessibleWrap::UpdateSystemCaretFor(
if (::CreateCaret(aCaretWnd, caretBitMap, 1,
aCaretRect.Height())) { // Also destroys the last caret
::ShowCaret(aCaretWnd);
POINT clientPoint{aCaretRect.X(), aCaretRect.Y()};
::ScreenToClient(aCaretWnd, &clientPoint);
::SetCaretPos(clientPoint.x, clientPoint.y);
RECT windowRect;
::GetWindowRect(aCaretWnd, &windowRect);
::SetCaretPos(aCaretRect.X() - windowRect.left,
aCaretRect.Y() - windowRect.top);
}
}
22 changes: 0 additions & 22 deletions accessible/xpcom/xpcAccessibleHyperText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,28 +246,6 @@ xpcAccessibleHyperText::SetCaretOffset(int32_t aCaretOffset) {
return NS_OK;
}

NS_IMETHODIMP
xpcAccessibleHyperText::GetCaretRect(int32_t* aX, int32_t* aY, int32_t* aWidth,
int32_t* aHeight) {
NS_ENSURE_ARG_POINTER(aX);
NS_ENSURE_ARG_POINTER(aY);
NS_ENSURE_ARG_POINTER(aWidth);
NS_ENSURE_ARG_POINTER(aHeight);
*aX = *aY = *aWidth = *aHeight;

if (!mIntl) {
return NS_ERROR_FAILURE;
}
if (mIntl->IsRemote()) {
return NS_ERROR_NOT_IMPLEMENTED;
}

nsIWidget* widget;
LayoutDeviceIntRect rect = IntlLocal()->GetCaretRect(&widget);
rect.GetRect(aX, aY, aWidth, aHeight);
return NS_OK;
}

NS_IMETHODIMP
xpcAccessibleHyperText::GetSelectionCount(int32_t* aSelectionCount) {
NS_ENSURE_ARG_POINTER(aSelectionCount);
Expand Down

0 comments on commit 6f5c0c5

Please sign in to comment.