Backed out 2 changesets (bug 1450927) for failing on ProxyAccessible.cpp(247) on a CLOSED TREE

Backed out changeset ca285aed3926 (bug 1450927)
Backed out changeset d7dd8b0d2473 (bug 1450927)
This commit is contained in:
Tiberius Oros 2018-04-25 19:31:50 +03:00
parent 65e4f92054
commit 2fffa00bb3
31 changed files with 72 additions and 249 deletions

View File

@ -144,12 +144,6 @@ Accessible::InsertAfter(Accessible* aNewChild, Accessible* aRefChild)
aNewChild);
}
inline nsIntRect
Accessible::Bounds() const
{
return BoundsInAppUnits().ToNearestPixels(mDoc->PresContext()->AppUnitsPerDevPixel());
}
} // namespace a11y
} // namespace mozilla

View File

@ -670,31 +670,32 @@ Accessible::RelativeBounds(nsIFrame** aBoundingFrame) const
return nsRect();
}
nsRect
Accessible::BoundsInAppUnits() const
nsIntRect
Accessible::Bounds() const
{
nsIFrame* boundingFrame = nullptr;
nsRect unionRectTwips = RelativeBounds(&boundingFrame);
if (!boundingFrame) {
return nsRect();
}
if (!boundingFrame)
return nsIntRect();
nsIntRect screenRect;
nsPresContext* presContext = mDoc->PresContext();
screenRect.SetRect(presContext->AppUnitsToDevPixels(unionRectTwips.X()),
presContext->AppUnitsToDevPixels(unionRectTwips.Y()),
presContext->AppUnitsToDevPixels(unionRectTwips.Width()),
presContext->AppUnitsToDevPixels(unionRectTwips.Height()));
// We need to take into account a non-1 resolution set on the presshell.
// This happens in mobile platforms with async pinch zooming. Here we
// scale the bounds before adding the screen-relative offset.
unionRectTwips.ScaleRoundOut(mDoc->PresContext()->PresShell()->GetResolution());
screenRect.ScaleRoundOut(presContext->PresShell()->GetResolution());
// We have the union of the rectangle, now we need to put it in absolute
// screen coords.
nsRect orgRectPixels = boundingFrame->GetScreenRectInAppUnits();
unionRectTwips.MoveBy(orgRectPixels.X(), orgRectPixels.Y());
nsIntRect orgRectPixels = boundingFrame->GetScreenRectInAppUnits().
ToNearestPixels(presContext->AppUnitsPerDevPixel());
screenRect.MoveBy(orgRectPixels.X(), orgRectPixels.Y());
return unionRectTwips;
}
nsIntRect
Accessible::BoundsInCSSPixels() const
{
return BoundsInAppUnits().ToNearestPixels(mDoc->PresContext()->AppUnitsPerCSSPixel());
return screenRect;
}
void

View File

@ -509,20 +509,10 @@ public:
virtual void AppendTextTo(nsAString& aText, uint32_t aStartOffset = 0,
uint32_t aLength = UINT32_MAX);
/**
* Return boundaries in screen coordinates in app units.
*/
virtual nsRect BoundsInAppUnits() const;
/**
* Return boundaries in screen coordinates.
*/
nsIntRect Bounds() const;
/**
* Return boundaries in screen coordinates in CSS pixels.
*/
virtual nsIntRect BoundsInCSSPixels() const;
virtual nsIntRect Bounds() const;
/**
* Return boundaries rect relative the bounding frame.

View File

@ -116,10 +116,10 @@ ApplicationAccessible::RelationByType(RelationType aRelationType)
return Relation();
}
nsRect
ApplicationAccessible::BoundsInAppUnits() const
nsIntRect
ApplicationAccessible::Bounds() const
{
return nsRect();
return nsIntRect();
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -36,7 +36,7 @@ public:
// Accessible
virtual void Shutdown() override;
virtual nsRect BoundsInAppUnits() const override;
virtual nsIntRect Bounds() const override;
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override;
virtual GroupPos GroupPosition() override;
virtual ENameValueFlag Name(nsString& aName) override;

View File

@ -74,15 +74,15 @@ HTMLLIAccessible::NativeState()
return HyperTextAccessibleWrap::NativeState() | states::READONLY;
}
nsRect
HTMLLIAccessible::BoundsInAppUnits() const
nsIntRect
HTMLLIAccessible::Bounds() const
{
nsRect rect = AccessibleWrap::BoundsInAppUnits();
if (rect.IsEmpty() || !mBullet || mBullet->IsInside()) {
nsIntRect rect = AccessibleWrap::Bounds();
if (rect.IsEmpty() || !mBullet || mBullet->IsInside())
return rect;
}
nsRect bulletRect = mBullet->BoundsInAppUnits();
nsIntRect bulletRect = mBullet->Bounds();
// Move x coordinate of list item over to cover bullet as well
rect.SetLeftEdge(bulletRect.X());
return rect;

View File

@ -51,7 +51,7 @@ public:
// Accessible
virtual void Shutdown() override;
virtual nsRect BoundsInAppUnits() const override;
virtual nsIntRect Bounds() const override;
virtual a11y::role NativeRole() override;
virtual uint64_t NativeState() override;

View File

@ -12,10 +12,6 @@ interface IGeckoCustom : IUnknown
{
[propget] HRESULT ID([out, retval] unsigned __int64* aID);
[propget] HRESULT anchorCount([out, retval] long* aCount);
[propget] HRESULT boundsInCSSPixels([out] long* aX,
[out] long* aY,
[out] long* aWidth,
[out, retval] long* aHeight);
[propget] HRESULT DOMNodeID([out, retval] BSTR* aID);
[propget] HRESULT minimumIncrement([out, retval] double* aIncrement);
[propget] HRESULT mozState([out, retval] unsigned __int64* aState);

View File

@ -20,11 +20,11 @@ class Accessible;
%}
/**
* A cross-platform interface that supports platform-specific
* A cross-platform interface that supports platform-specific
* accessibility APIs like MSAA and ATK. Contains the sum of what's needed
* to support IAccessible as well as ATK's generic accessibility objects.
* Can also be used by in-process accessibility clients to get information
* about objects in the accessible tree. The accessible tree is a subset of
* about objects in the accessible tree. The accessible tree is a subset of
* nodes in the DOM tree -- such as documents, focusable elements and text.
* Mozilla creates the implementations of nsIAccessible on demand.
* See http://www.mozilla.org/projects/ui/accessibility for more information.
@ -56,7 +56,7 @@ interface nsIAccessible : nsISupports
* Last child in accessible tree
*/
readonly attribute nsIAccessible lastChild;
/**
* Array of all this element's children.
*/
@ -124,7 +124,7 @@ interface nsIAccessible : nsISupports
/**
* Provides localized string of accesskey name, such as Alt+D.
* The modifier may be affected by user and platform preferences.
* Usually alt+letter, or just the letter alone for menu items.
* Usually alt+letter, or just the letter alone for menu items.
*/
readonly attribute AString accessKey;
@ -226,16 +226,10 @@ interface nsIAccessible : nsISupports
/**
* Return accessible's x and y coordinates relative to the screen and
* accessible's width and height in Dev pixels.
* accessible's width and height.
*/
void getBounds(out long x, out long y, out long width, out long height);
/**
* Return accessible's x and y coordinates relative to the screen and
* accessible's width and height in CSS pixels.
*/
void getBoundsInCSSPixels(out long aX, out long aY, out long aWidth, out long aHeight);
/**
* Add or remove this accessible to the current selection
*/

View File

@ -253,7 +253,6 @@ ProxyAccessible* FocusedChild();
ProxyAccessible* ChildAtPoint(int32_t aX, int32_t aY,
Accessible::EWhichChildAtPoint aWhichChild);
nsIntRect Bounds();
nsIntRect BoundsInCSSPixels();
void Language(nsString& aLocale);
void DocType(nsString& aType);

View File

@ -1983,30 +1983,6 @@ DocAccessibleChild::RecvExtents(const uint64_t& aID,
return IPC_OK();
}
mozilla::ipc::IPCResult
DocAccessibleChild::RecvExtentsInCSSPixels(const uint64_t& aID,
int32_t* aX,
int32_t* aY,
int32_t* aWidth,
int32_t* aHeight)
{
*aX = 0;
*aY = 0;
*aWidth = 0;
*aHeight = 0;
Accessible* acc = IdToAccessible(aID);
if (acc && !acc->IsDefunct()) {
nsIntRect screenRect = acc->BoundsInCSSPixels();
if (!screenRect.IsEmpty()) {
*aX = screenRect.x;
*aY = screenRect.y;
*aWidth = screenRect.width;
*aHeight = screenRect.height;
}
}
return IPC_OK();
}
mozilla::ipc::IPCResult
DocAccessibleChild::RecvDOMNodeID(const uint64_t& aID, nsString* aDOMNodeID)
{

View File

@ -470,11 +470,6 @@ public:
int32_t* aY,
int32_t* aWidth,
int32_t* aHeight) override;
virtual mozilla::ipc::IPCResult RecvExtentsInCSSPixels(const uint64_t& aID,
int32_t* aX,
int32_t* aY,
int32_t* aWidth,
int32_t* aHeight) override;
virtual mozilla::ipc::IPCResult RecvDOMNodeID(const uint64_t& aID, nsString* aDOMNodeID) override;
private:

View File

@ -265,8 +265,6 @@ child:
nested(inside_sync) sync Extents(uint64_t aID, bool aNeedsScreenCoords)
returns(int32_t aX, int32_t aY, int32_t aWidth, int32_t aHeight);
nested(inside_sync) sync ExtentsInCSSPixels(uint64_t aID)
returns(int32_t aX, int32_t aY, int32_t aWidth, int32_t aHeight);
nested(inside_sync) sync DOMNodeID(uint64_t aID) returns(nsString aDOMNodeID);
};

View File

@ -1013,16 +1013,6 @@ ProxyAccessible::Bounds()
return rect;
}
nsIntRect
ProxyAccessible::BoundsInCSSPixels()
{
nsIntRect rect;
Unused << mDoc->SendExtentsInCSSPixels(mID,
&rect.x, &rect.y,
&rect.width, &rect.height);
return rect;
}
void
ProxyAccessible::Language(nsString& aLocale)
{

View File

@ -235,19 +235,6 @@ ProxyAccessible::Bounds()
return rect;
}
nsIntRect
ProxyAccessible::BoundsInCSSPixels()
{
RefPtr<IGeckoCustom> custom = QueryInterface<IGeckoCustom>(this);
if (!custom) {
return nsIntRect();
}
nsIntRect rect;
HRESULT hr = custom->get_boundsInCSSPixels(&rect.x, &rect.y, &rect.width, &rect.height);
return rect;
}
void
ProxyAccessible::Language(nsString& aLocale)
{

View File

@ -6,8 +6,6 @@
/* import-globals-from ../../mochitest/layout.js */
/* global getContentDPR */
async function getContentBoundsForDOMElm(browser, id) {
return ContentTask.spawn(browser, id, contentId => {
this.ok = ok;
@ -19,13 +17,12 @@ async function testContentBounds(browser, acc) {
let [expectedX, expectedY, expectedWidth, expectedHeight] =
await getContentBoundsForDOMElm(browser, getAccessibleDOMNodeID(acc));
let contentDPR = await getContentDPR(browser);
let [x, y, width, height] = getBounds(acc, contentDPR);
let [x, y, width, height] = getBounds(acc);
let prettyAccName = prettyName(acc);
is(x, expectedX, "Wrong x coordinate of " + prettyAccName);
is(y, expectedY, "Wrong y coordinate of " + prettyAccName);
is(width, expectedWidth, "Wrong width of " + prettyAccName);
ok(height >= expectedHeight, "Wrong height of " + prettyAccName);
is(height, expectedHeight, "Wrong height of " + prettyAccName);
}
async function runTests(browser, accDoc) {

View File

@ -6,29 +6,26 @@
/* import-globals-from ../../mochitest/layout.js */
/* global getContentDPR */
async function runTests(browser, accDoc) {
async function testTextNode(id) {
function testTextNode(id) {
let hyperTextNode = findAccessibleChildByID(accDoc, id);
let textNode = hyperTextNode.firstChild;
let contentDPR = await getContentDPR(browser);
let [x, y, width, height] = getBounds(textNode, contentDPR);
let [x, y, width, height] = getBounds(textNode);
testTextBounds(hyperTextNode, 0, -1, [x, y, width, height],
COORDTYPE_SCREEN_RELATIVE);
}
loadFrameScripts(browser, { name: "layout.js", dir: MOCHITESTS_DIR });
await testTextNode("p1");
await testTextNode("p2");
testTextNode("p1");
testTextNode("p2");
await ContentTask.spawn(browser, {}, () => {
zoomDocument(document, 2.0);
});
await testTextNode("p1");
testTextNode("p1");
await ContentTask.spawn(browser, {}, () => {
zoomDocument(document, 1.0);

View File

@ -6,9 +6,6 @@
// Load the shared-head file first.
/* import-globals-from ../shared-head.js */
/* exported getContentDPR */
Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/accessible/tests/browser/shared-head.js",
this);
@ -17,10 +14,3 @@ Services.scriptloader.loadSubScript(
// well as events.js.
loadScripts({ name: "common.js", dir: MOCHITESTS_DIR },
{ name: "layout.js", dir: MOCHITESTS_DIR }, "events.js");
/**
* Get content window DPR that can be different from parent window DPR.
*/
async function getContentDPR(browser) {
return ContentTask.spawn(browser, null, () => content.window.devicePixelRatio);
}

View File

@ -46,8 +46,8 @@
"Outside list item y should match to list item element y");
ok(widthLI > widthLIElm,
"Outside list item width=" + widthLI + " should be greater than list item element width=" + widthLIElm);
ok(heightLI > heightLIElm,
"Outside list item height=" + heightLI + " should be greater than list item element height=" + heightLIElm);
is(heightLI, heightLIElm,
"Outside list item height should match to list item element height");
SimpleTest.finish();
}

View File

@ -199,25 +199,12 @@ function getPos(aID) {
/**
* Return the accessible coordinates and size relative to the screen in device
* pixels. This methods also retrieves coordinates in CSS pixels and ensures that they
* match Dev pixels with a given device pixel ratio.
* pixels.
*/
function getBounds(aID, aDPR = window.devicePixelRatio) {
const accessible = getAccessible(aID);
let x = {}, y = {}, width = {}, height = {};
let xInCSS = {}, yInCSS = {}, widthInCSS = {}, heightInCSS = {};
function getBounds(aID) {
var accessible = getAccessible(aID);
var x = {}, y = {}, width = {}, height = {};
accessible.getBounds(x, y, width, height);
accessible.getBoundsInCSSPixels(xInCSS, yInCSS, widthInCSS, heightInCSS);
ok(Math.trunc(x.value / aDPR) <= xInCSS.value,
"X in CSS pixels is calculated correctly");
ok(Math.trunc(y.value / aDPR) <= yInCSS.value,
"Y in CSS pixels is calculated correctly");
ok(Math.trunc(width.value / aDPR) <= widthInCSS.value,
"Width in CSS pixels is calculated correctly");
ok(Math.trunc(height.value / aDPR) <= heightInCSS.value,
"Heights in CSS pixels is calculated correctly");
return [x.value, y.value, width.value, height.value];
}

View File

@ -20,20 +20,6 @@ GeckoCustom::get_anchorCount(long* aCount)
return S_OK;
}
HRESULT
GeckoCustom::get_boundsInCSSPixels(long* aX, long* aY, long* aWidth, long* aHeight)
{
nsIntRect bounds = mAcc->BoundsInCSSPixels();
if (!bounds.IsEmpty()) {
*aX = bounds.X();
*aY = bounds.Y();
*aWidth = bounds.Width();
*aHeight = bounds.Height();
}
return S_OK;
}
HRESULT
GeckoCustom::get_DOMNodeID(BSTR* aID)
{

View File

@ -27,7 +27,6 @@ public:
DECL_IUNKNOWN
virtual STDMETHODIMP get_anchorCount(long* aCount);
virtual STDMETHODIMP get_boundsInCSSPixels(long* aX, long* aY, long* aWidth, long* aHeight);
virtual STDMETHODIMP get_DOMNodeID(BSTR* aID);
virtual STDMETHODIMP get_ID(uint64_t* aID);
virtual STDMETHODIMP get_minimumIncrement(double* aIncrement);

View File

@ -456,34 +456,6 @@ xpcAccessible::GetBounds(int32_t* aX, int32_t* aY,
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GetBoundsInCSSPixels(int32_t* aX, int32_t* aY,
int32_t* aWidth, int32_t* aHeight)
{
NS_ENSURE_ARG_POINTER(aX);
*aX = 0;
NS_ENSURE_ARG_POINTER(aY);
*aY = 0;
NS_ENSURE_ARG_POINTER(aWidth);
*aWidth = 0;
NS_ENSURE_ARG_POINTER(aHeight);
*aHeight = 0;
if (IntlGeneric().IsNull()) {
return NS_ERROR_FAILURE;
}
nsIntRect rect;
if (Accessible* acc = IntlGeneric().AsAccessible()) {
rect = acc->BoundsInCSSPixels();
} else {
rect = IntlGeneric().AsProxy()->BoundsInCSSPixels();
}
rect.GetRect(aX, aY, aWidth, aHeight);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessible::GroupPosition(int32_t* aGroupLevel,
int32_t* aSimilarItemsInGroup,

View File

@ -60,8 +60,6 @@ public:
final;
NS_IMETHOD GetBounds(int32_t* aX, int32_t* aY,
int32_t* aWidth, int32_t* aHeight) final;
NS_IMETHOD GetBoundsInCSSPixels(int32_t* aX, int32_t* aY,
int32_t* aWidth, int32_t* aHeight) final;
NS_IMETHOD GroupPosition(int32_t* aGroupLevel, int32_t* aSimilarItemsInGroup,
int32_t* aPositionInGroup) final;
NS_IMETHOD GetRelationByType(uint32_t aType,

View File

@ -723,24 +723,22 @@ XULTreeItemAccessibleBase::FocusedChild()
}
nsIntRect
XULTreeItemAccessibleBase::BoundsInCSSPixels() const
XULTreeItemAccessibleBase::Bounds() const
{
// Get x coordinate and width from treechildren element, get y coordinate and
// height from tree cell.
nsCOMPtr<nsIBoxObject> boxObj = nsCoreUtils::GetTreeBodyBoxObject(mTree);
if (!boxObj) {
if (!boxObj)
return nsIntRect();
}
nsCOMPtr<nsITreeColumn> column = nsCoreUtils::GetFirstSensibleColumn(mTree);
int32_t x = 0, y = 0, width = 0, height = 0;
nsresult rv = mTree->GetCoordsForCellItem(mRow, column, EmptyString(),
&x, &y, &width, &height);
if (NS_FAILED(rv)) {
if (NS_FAILED(rv))
return nsIntRect();
}
boxObj->GetWidth(&width);
@ -751,18 +749,11 @@ XULTreeItemAccessibleBase::BoundsInCSSPixels() const
x = tcX;
y += tcY;
return nsIntRect(x, y, width, height);
}
nsRect
XULTreeItemAccessibleBase::BoundsInAppUnits() const
{
nsIntRect bounds = BoundsInCSSPixels();
nsPresContext* presContext = mDoc->PresContext();
return nsRect(presContext->CSSPixelsToAppUnits(bounds.X()),
presContext->CSSPixelsToAppUnits(bounds.Y()),
presContext->CSSPixelsToAppUnits(bounds.Width()),
presContext->CSSPixelsToAppUnits(bounds.Height()));
return nsIntRect(presContext->CSSPixelsToDevPixels(x),
presContext->CSSPixelsToDevPixels(y),
presContext->CSSPixelsToDevPixels(width),
presContext->CSSPixelsToDevPixels(height));
}
void

View File

@ -146,8 +146,7 @@ public:
// Accessible
virtual void Shutdown() override;
virtual nsRect BoundsInAppUnits() const override;
virtual nsIntRect BoundsInCSSPixels() const override;
virtual nsIntRect Bounds() const override;
virtual GroupPos GroupPosition() override;
virtual uint64_t NativeState() override;
virtual uint64_t NativeInteractiveState() const override;

View File

@ -495,22 +495,20 @@ XULTreeGridCellAccessible::Name(nsString& aName)
}
nsIntRect
XULTreeGridCellAccessible::BoundsInCSSPixels() const
XULTreeGridCellAccessible::Bounds() const
{
// Get bounds for tree cell and add x and y of treechildren element to
// x and y of the cell.
nsCOMPtr<nsIBoxObject> boxObj = nsCoreUtils::GetTreeBodyBoxObject(mTree);
if (!boxObj) {
if (!boxObj)
return nsIntRect();
}
int32_t x = 0, y = 0, width = 0, height = 0;
nsresult rv = mTree->GetCoordsForCellItem(mRow, mColumn,
NS_LITERAL_STRING("cell"),
&x, &y, &width, &height);
if (NS_FAILED(rv)) {
if (NS_FAILED(rv))
return nsIntRect();
}
int32_t tcX = 0, tcY = 0;
boxObj->GetScreenX(&tcX);
@ -518,18 +516,11 @@ XULTreeGridCellAccessible::BoundsInCSSPixels() const
x += tcX;
y += tcY;
return nsIntRect(x, y, width, height);
}
nsRect
XULTreeGridCellAccessible::BoundsInAppUnits() const
{
nsIntRect bounds = BoundsInCSSPixels();
nsPresContext* presContext = mDoc->PresContext();
return nsRect(presContext->CSSPixelsToAppUnits(bounds.X()),
presContext->CSSPixelsToAppUnits(bounds.Y()),
presContext->CSSPixelsToAppUnits(bounds.Width()),
presContext->CSSPixelsToAppUnits(bounds.Height()));
return nsIntRect(presContext->CSSPixelsToDevPixels(x),
presContext->CSSPixelsToDevPixels(y),
presContext->CSSPixelsToDevPixels(width),
presContext->CSSPixelsToDevPixels(height));
}
uint8_t

View File

@ -126,8 +126,7 @@ public:
// Accessible
virtual void Shutdown() override;
virtual TableCellAccessible* AsTableCell() override { return this; }
virtual nsRect BoundsInAppUnits() const override;
virtual nsIntRect BoundsInCSSPixels() const override;
virtual nsIntRect Bounds() const override;
virtual ENameValueFlag Name(nsString& aName) override;
virtual Accessible* FocusedChild() override;
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override;

View File

@ -325,7 +325,7 @@ const AccessibleActor = ActorClassWithSpec(accessibleSpec, {
let x = {}, y = {}, w = {}, h = {};
try {
this.rawAccessible.getBoundsInCSSPixels(x, y, w, h);
this.rawAccessible.getBounds(x, y, w, h);
x = x.value;
y = y.value;
w = w.value;

View File

@ -26,19 +26,19 @@ const { getCurrentZoom } = require("devtools/shared/layout/utils");
* the accessible object.
*/
function getBounds(win, { x, y, w, h }) {
let { mozInnerScreenX, mozInnerScreenY, scrollX, scrollY } = win;
let { devicePixelRatio, mozInnerScreenX, mozInnerScreenY, scrollX, scrollY } = win;
let zoom = getCurrentZoom(win);
let left = x, right = x + w, top = y, bottom = y + h;
left -= mozInnerScreenX - scrollX;
right -= mozInnerScreenX - scrollX;
top -= mozInnerScreenY - scrollY;
bottom -= mozInnerScreenY - scrollY;
left -= (mozInnerScreenX - scrollX) * devicePixelRatio;
right -= (mozInnerScreenX - scrollX) * devicePixelRatio;
top -= (mozInnerScreenY - scrollY) * devicePixelRatio;
bottom -= (mozInnerScreenY - scrollY) * devicePixelRatio;
left *= zoom;
right *= zoom;
top *= zoom;
bottom *= zoom;
left *= zoom / devicePixelRatio;
right *= zoom / devicePixelRatio;
top *= zoom / devicePixelRatio;
bottom *= zoom / devicePixelRatio;
let width = right - left;
let height = bottom - top;

View File

@ -594,9 +594,6 @@ platform = notwin
[PDocAccessible::Extents]
description =
platform = notwin
[PDocAccessible::ExtentsInCSSPixels]
description =
platform = notwin
[PDocAccessible::DOMNodeID]
description =
platform = notwin