mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 02:25:34 +00:00
Bug 1733440: Adjust RemoteAccessibleBase::Bounds for root relative coordinates r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D127848
This commit is contained in:
parent
f3cfbdb6aa
commit
02b4894dca
@ -646,12 +646,40 @@ nsRect LocalAccessible::ParentRelativeBounds() {
|
||||
}
|
||||
}
|
||||
|
||||
if (mParent) {
|
||||
boundingFrame = mParent->GetFrame();
|
||||
// We need to find a frame to make our bounds relative to. We'll store this
|
||||
// in `boundingFrame`. Ultimately, we'll create screen-relative coordinates
|
||||
// by summing the x, y offsets of our ancestors' bounds in
|
||||
// RemoteAccessibleBase::Bounds(), so it is important that our bounding
|
||||
// frame have a corresponding accessible.
|
||||
if (IsDoc() &&
|
||||
nsCoreUtils::IsTopLevelContentDocInProcess(AsDoc()->DocumentNode())) {
|
||||
// Tab documents and OOP iframe docs won't have ancestor accessibles with
|
||||
// frames. We'll use their presshell root frame instead.
|
||||
// XXX bug 1736635: Should DocAccessibles return their presShell frame on
|
||||
// GetFrame()?
|
||||
boundingFrame = nsLayoutUtils::GetContainingBlockForClientRect(frame);
|
||||
}
|
||||
|
||||
// Iterate through ancestors to find one with a frame.
|
||||
LocalAccessible* parent = mParent;
|
||||
while (parent && !boundingFrame) {
|
||||
if (parent->IsDoc()) {
|
||||
// If we find a doc accessible, use its presshell's root frame
|
||||
// (since doc accessibles themselves don't have frames).
|
||||
boundingFrame = nsLayoutUtils::GetContainingBlockForClientRect(frame);
|
||||
break;
|
||||
}
|
||||
|
||||
if ((boundingFrame = parent->GetFrame())) {
|
||||
// Otherwise, if the parent has a frame, use that
|
||||
break;
|
||||
}
|
||||
|
||||
parent = parent->LocalParent();
|
||||
}
|
||||
|
||||
if (!boundingFrame) {
|
||||
// if we can't get the bounding frame, use the pres shell root
|
||||
MOZ_ASSERT_UNREACHABLE("No ancestor with frame?");
|
||||
boundingFrame = nsLayoutUtils::GetContainingBlockForClientRect(frame);
|
||||
}
|
||||
|
||||
|
@ -14,3 +14,4 @@ skip-if = webrender # Bug 1734271
|
||||
https_first_disabled = true
|
||||
skip-if = e10s && os == 'win' # bug 1372296
|
||||
[browser_zero_area.js]
|
||||
[browser_test_display_contents.js]
|
||||
|
@ -0,0 +1,48 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from ../../mochitest/layout.js */
|
||||
|
||||
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 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);
|
||||
}
|
||||
|
||||
async function runTests(browser, accDoc) {
|
||||
let p = findAccessibleChildByID(accDoc, "div");
|
||||
let p2 = findAccessibleChildByID(accDoc, "p");
|
||||
|
||||
await testContentBounds(browser, p);
|
||||
await testContentBounds(browser, p2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test accessible bounds for accs with display:contents
|
||||
*/
|
||||
addAccessibleTask(
|
||||
`
|
||||
<div id="div">before
|
||||
<ul id="ul" style="display: contents;">
|
||||
<li id="li" style="display: contents;">
|
||||
<p id="p">item</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>`,
|
||||
runTests,
|
||||
{ iframe: true, remoteIframe: true }
|
||||
);
|
Loading…
Reference in New Issue
Block a user