mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-24 10:45:42 +00:00
Bug 1542756 - Bug 1543128 - Add option to only return visible nodes from nsIDOMWindowUtils.nodesFromRect. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D26809 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
ab6c5e1a60
commit
0d5744162f
@ -248,7 +248,7 @@ DownloadsPlacesView.prototype = {
|
||||
let winUtils = window.windowUtils;
|
||||
let nodes = winUtils.nodesFromRect(rlbRect.left, rlbRect.top,
|
||||
0, rlbRect.width, rlbRect.height, 0,
|
||||
true, false);
|
||||
true, false, false);
|
||||
// nodesFromRect returns nodes in z-index order, and for the same z-index
|
||||
// sorts them in inverted DOM order, thus starting from the one that would
|
||||
// be on top.
|
||||
|
@ -362,6 +362,7 @@ void DocumentOrShadowRoot::NodesFromRect(float aX, float aY, float aTopSize,
|
||||
float aLeftSize,
|
||||
bool aIgnoreRootScrollFrame,
|
||||
bool aFlushLayout,
|
||||
bool aOnlyVisible,
|
||||
nsTArray<RefPtr<nsINode>>& aReturn) {
|
||||
// Following the same behavior of elementFromPoint,
|
||||
// we don't return anything if either coord is negative
|
||||
@ -380,6 +381,9 @@ void DocumentOrShadowRoot::NodesFromRect(float aX, float aY, float aTopSize,
|
||||
if (aIgnoreRootScrollFrame) {
|
||||
options += FrameForPointOption::IgnoreRootScrollFrame;
|
||||
}
|
||||
if (aOnlyVisible) {
|
||||
options += FrameForPointOption::OnlyVisible;
|
||||
}
|
||||
|
||||
auto flush = aFlushLayout ? FlushLayout::Yes : FlushLayout::No;
|
||||
QueryNodesFromRect(*this, rect, options, flush, Multiple::Yes, aReturn);
|
||||
|
@ -120,7 +120,7 @@ class DocumentOrShadowRoot {
|
||||
void NodesFromRect(float aX, float aY, float aTopSize, float aRightSize,
|
||||
float aBottomSize, float aLeftSize,
|
||||
bool aIgnoreRootScrollFrame, bool aFlushLayout,
|
||||
nsTArray<RefPtr<nsINode>>&);
|
||||
bool aOnlyVisible, nsTArray<RefPtr<nsINode>>&);
|
||||
|
||||
/**
|
||||
* This gets fired when the element that an id refers to changes.
|
||||
|
@ -1155,7 +1155,8 @@ NS_IMETHODIMP
|
||||
nsDOMWindowUtils::NodesFromRect(float aX, float aY, float aTopSize,
|
||||
float aRightSize, float aBottomSize,
|
||||
float aLeftSize, bool aIgnoreRootScrollFrame,
|
||||
bool aFlushLayout, nsINodeList** aReturn) {
|
||||
bool aFlushLayout, bool aOnlyVisible,
|
||||
nsINodeList** aReturn) {
|
||||
nsCOMPtr<Document> doc = GetDocument();
|
||||
NS_ENSURE_STATE(doc);
|
||||
|
||||
@ -1165,7 +1166,8 @@ nsDOMWindowUtils::NodesFromRect(float aX, float aY, float aTopSize,
|
||||
|
||||
AutoTArray<RefPtr<nsINode>, 8> nodes;
|
||||
doc->NodesFromRect(aX, aY, aTopSize, aRightSize, aBottomSize, aLeftSize,
|
||||
aIgnoreRootScrollFrame, aFlushLayout, nodes);
|
||||
aIgnoreRootScrollFrame, aFlushLayout, aOnlyVisible,
|
||||
nodes);
|
||||
list->SetCapacity(nodes.Length());
|
||||
for (auto& node : nodes) {
|
||||
list->AppendElement(node->AsContent());
|
||||
|
@ -745,6 +745,8 @@ interface nsIDOMWindowUtils : nsISupports {
|
||||
* frame when retrieving the element. If false, this method returns
|
||||
* null for coordinates outside of the viewport.
|
||||
* @param aFlushLayout flushes layout if true. Otherwise, no flush occurs.
|
||||
* @param aOnlyVisible Set to true if you only want nodes that pass a visibility
|
||||
* hit test.
|
||||
*/
|
||||
NodeList nodesFromRect(in float aX,
|
||||
in float aY,
|
||||
@ -753,7 +755,8 @@ interface nsIDOMWindowUtils : nsISupports {
|
||||
in float aBottomSize,
|
||||
in float aLeftSize,
|
||||
in boolean aIgnoreRootScrollFrame,
|
||||
in boolean aFlushLayout);
|
||||
in boolean aFlushLayout,
|
||||
in boolean aOnlyVisible);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -13,20 +13,8 @@
|
||||
|
||||
let dwu = window.windowUtils;
|
||||
|
||||
/*
|
||||
NodeList nodesFromRect(in float aX,
|
||||
in float aY,
|
||||
in float aTopSize,
|
||||
in float aRightSize,
|
||||
in float aBottomSize,
|
||||
in float aLeftSize,
|
||||
in boolean aIgnoreRootScrollFrame,
|
||||
in boolean aFlushLayout);
|
||||
|
||||
*/
|
||||
|
||||
function check(x, y, top, right, bottom, left, list) {
|
||||
let nodes = dwu.nodesFromRect(x, y, top, right, bottom, left, true, false);
|
||||
let nodes = dwu.nodesFromRect(x, y, top, right, bottom, left, true, false, false);
|
||||
|
||||
list.push(e.body);
|
||||
list.push(e.html);
|
||||
|
@ -299,7 +299,7 @@ class PictureInPictureToggleChild extends ActorChild {
|
||||
// since document.elementsFromPoint always flushes layout. The 1's in that
|
||||
// function call are for the size of the rect that we want, which is 1x1.
|
||||
let elements = winUtils.nodesFromRect(clientX, clientY, 1, 1, 1, 1, true,
|
||||
false);
|
||||
false, false);
|
||||
|
||||
for (let element of elements) {
|
||||
if (state.weakVisibleVideos.has(element) &&
|
||||
|
Loading…
Reference in New Issue
Block a user