Bug 1948522 - Make nsIDOMWindowUtils.getContentAPZTestData work for poup. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D238552
This commit is contained in:
@@ -4176,8 +4176,9 @@ nsDOMWindowUtils::IsKeyboardEventUserActivity(Event* aEvent, bool* aResult) {
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::GetContentAPZTestData(
|
||||
JSContext* aContext, JS::MutableHandle<JS::Value> aOutContentTestData) {
|
||||
if (nsIWidget* widget = GetWidget()) {
|
||||
Element* aElement, JSContext* aContext,
|
||||
JS::MutableHandle<JS::Value> aOutContentTestData) {
|
||||
if (nsIWidget* widget = GetWidgetForElement(aElement)) {
|
||||
WindowRenderer* renderer = widget->GetWindowRenderer();
|
||||
if (!renderer) {
|
||||
return NS_OK;
|
||||
|
||||
@@ -2005,8 +2005,11 @@ interface nsIDOMWindowUtils : nsISupports {
|
||||
/**
|
||||
* Get the content- and compositor-side APZ test data instances.
|
||||
* The return values are of type APZTestData (see APZTestData.webidl).
|
||||
*
|
||||
* |aElement| is an optional argument for popup window where APZ is enabled.
|
||||
* |aElement| would be a popup element for popup
|
||||
*/
|
||||
[implicit_jscontext] jsval getContentAPZTestData();
|
||||
[implicit_jscontext] jsval getContentAPZTestData([optional] in Element aElement);
|
||||
|
||||
/*
|
||||
* |aElement| is an optional argument for popup window where APZ is enabled.
|
||||
|
||||
@@ -244,16 +244,20 @@ function isLayerized(elementId) {
|
||||
// Return a rect (or null) that holds the last known content-side displayport
|
||||
// for a given element. (The element selection works the same way, and with
|
||||
// the same assumptions as the isLayerized function above).
|
||||
function getLastContentDisplayportFor(elementId, expectPainted = true) {
|
||||
var contentTestData =
|
||||
SpecialPowers.getDOMWindowUtils(window).getContentAPZTestData();
|
||||
function getLastContentDisplayportFor(
|
||||
aElementId,
|
||||
aOptions = { expectPainted: true, popupElement: null }
|
||||
) {
|
||||
var contentTestData = SpecialPowers.getDOMWindowUtils(
|
||||
aOptions.popupElement ? aOptions.popupElement.ownerGlobal : window
|
||||
).getContentAPZTestData(aOptions.popupElement);
|
||||
if (contentTestData == undefined) {
|
||||
ok(!expectPainted, "expected to have apz test data (1)");
|
||||
ok(!aOptions.expectPainted, "expected to have apz test data (1)");
|
||||
return null;
|
||||
}
|
||||
var nonEmptyBucket = getLastNonemptyBucket(contentTestData.paints);
|
||||
if (nonEmptyBucket == null) {
|
||||
ok(!expectPainted, "expected to have apz test data (2)");
|
||||
ok(!aOptions.expectPainted, "expected to have apz test data (2)");
|
||||
return null;
|
||||
}
|
||||
var seqno = nonEmptyBucket.sequenceNumber;
|
||||
@@ -261,7 +265,7 @@ function getLastContentDisplayportFor(elementId, expectPainted = true) {
|
||||
var paint = contentTestData.paints[seqno];
|
||||
for (var scrollId in paint) {
|
||||
if ("contentDescription" in paint[scrollId]) {
|
||||
if (paint[scrollId].contentDescription.includes(elementId)) {
|
||||
if (paint[scrollId].contentDescription.includes(aElementId)) {
|
||||
if ("displayport" in paint[scrollId]) {
|
||||
return parseRect(paint[scrollId].displayport);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,9 @@
|
||||
|
||||
function getIframeDisplayport(iframe) {
|
||||
return SpecialPowers.spawn(iframe, [], () => {
|
||||
return content.wrappedJSObject.getLastContentDisplayportFor("fission_empty_docelement", false);
|
||||
return content.wrappedJSObject.getLastContentDisplayportFor(
|
||||
"fission_empty_docelement", { expectPainted: false }
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,10 @@
|
||||
|
||||
async function getIframeDisplayport(iframe) {
|
||||
return SpecialPowers.spawn(iframe, [], () => {
|
||||
return content.wrappedJSObject.getLastContentDisplayportFor("fission_empty_docelement", false);
|
||||
return content.wrappedJSObject.getLastContentDisplayportFor(
|
||||
"fission_empty_docelement",
|
||||
{ expectPainted: false }
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,10 @@ html {
|
||||
parent.postMessage("wereDone", "*");
|
||||
return;
|
||||
}
|
||||
let dp = getLastContentDisplayportFor("helper_wide_crossorigin_iframe_child_docelement", /* expectPainted = */ false);
|
||||
let dp = getLastContentDisplayportFor(
|
||||
"helper_wide_crossorigin_iframe_child_docelement",
|
||||
{ expectPainted: false }
|
||||
);
|
||||
if (dp != null) {
|
||||
info("result " + dp.x + " " + dp.y + " " + dp.width + " " + dp.height);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user