mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
browser(firefox): another way to report elements without layout object (#2597)
This commit is contained in:
parent
0369062717
commit
ab5f5c8b78
@ -1 +1 @@
|
|||||||
1110
|
1111
|
||||||
|
@ -621,23 +621,12 @@ class PageAgent {
|
|||||||
const unsafeObject = this._frameData.get(frame).unsafeObject(objectId);
|
const unsafeObject = this._frameData.get(frame).unsafeObject(objectId);
|
||||||
if (!unsafeObject.isConnected)
|
if (!unsafeObject.isConnected)
|
||||||
throw new Error('Node is detached from document');
|
throw new Error('Node is detached from document');
|
||||||
if (!unsafeObject.ownerDocument || !unsafeObject.ownerDocument.defaultView)
|
|
||||||
throw new Error('Node is detached from document');
|
|
||||||
const element = unsafeObject.nodeType === 1 ? unsafeObject : unsafeObject.parentElement;
|
|
||||||
if (!element)
|
|
||||||
throw new Error('Node is detached from document');
|
|
||||||
const style = unsafeObject.ownerDocument.defaultView.getComputedStyle(element);
|
|
||||||
if (!style || style.visibility === 'hidden')
|
|
||||||
throw new Error('Node is not visible');
|
|
||||||
const bounds = element.getBoundingClientRect();
|
|
||||||
if (bounds.width <= 0 || bounds.height <= 0)
|
|
||||||
throw new Error('Node is not visible');
|
|
||||||
if (!rect)
|
if (!rect)
|
||||||
rect = { x: -1, y: -1, width: -1, height: -1};
|
rect = { x: -1, y: -1, width: -1, height: -1};
|
||||||
if (unsafeObject.scrollRectIntoViewIfNeeded)
|
if (unsafeObject.scrollRectIntoViewIfNeeded)
|
||||||
unsafeObject.scrollRectIntoViewIfNeeded(rect.x, rect.y, rect.width, rect.height);
|
unsafeObject.scrollRectIntoViewIfNeeded(rect.x, rect.y, rect.width, rect.height);
|
||||||
else
|
else
|
||||||
throw new Error('Node type does not support scrollRectIntoViewIfNeeded');
|
throw new Error('Node does not have a layout object');
|
||||||
}
|
}
|
||||||
|
|
||||||
_getNodeBoundingBox(unsafeObject) {
|
_getNodeBoundingBox(unsafeObject) {
|
||||||
|
@ -671,7 +671,7 @@ index da9d56e843a2c762dc7d5527712cdd3d30418f7f..ea9d962513dfc02682d5dfd543dd72ba
|
|||||||
}
|
}
|
||||||
|
|
||||||
diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp
|
diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp
|
||||||
index 7c0d4bd261bf053c7cab4091522dc1e52118eba1..9af7b44c443955dc6355197bb94f65c229d165a3 100644
|
index 7c0d4bd261bf053c7cab4091522dc1e52118eba1..e320e6bfb0402eb07ae53272264278bad9638519 100644
|
||||||
--- a/dom/base/nsINode.cpp
|
--- a/dom/base/nsINode.cpp
|
||||||
+++ b/dom/base/nsINode.cpp
|
+++ b/dom/base/nsINode.cpp
|
||||||
@@ -1260,6 +1260,48 @@ void nsINode::GetBoxQuadsFromWindowOrigin(const BoxQuadOptions& aOptions,
|
@@ -1260,6 +1260,48 @@ void nsINode::GetBoxQuadsFromWindowOrigin(const BoxQuadOptions& aOptions,
|
||||||
@ -684,19 +684,19 @@ index 7c0d4bd261bf053c7cab4091522dc1e52118eba1..9af7b44c443955dc6355197bb94f65c2
|
|||||||
+ aRv = NS_ERROR_UNEXPECTED;
|
+ aRv = NS_ERROR_UNEXPECTED;
|
||||||
+ nsCOMPtr<Document> document = OwnerDoc();
|
+ nsCOMPtr<Document> document = OwnerDoc();
|
||||||
+ if (!document) {
|
+ if (!document) {
|
||||||
+ return;
|
+ return aRv.ThrowNotFoundError("Node is detached from document");
|
||||||
+ }
|
+ }
|
||||||
+ PresShell* presShell = document->GetPresShell();
|
+ PresShell* presShell = document->GetPresShell();
|
||||||
+ if (!presShell) {
|
+ if (!presShell) {
|
||||||
+ return;
|
+ return aRv.ThrowNotFoundError("Node is detached from document");
|
||||||
+ }
|
+ }
|
||||||
+ if (!IsContent()) {
|
+ if (!IsContent()) {
|
||||||
+ return;
|
+ return aRv.ThrowNotFoundError("Node does not have a layout object");
|
||||||
+ }
|
+ }
|
||||||
+ aRv = NS_OK;
|
+ aRv = NS_OK;
|
||||||
+ nsIFrame* primaryFrame = AsContent()->GetPrimaryFrame(FlushType::Frames);
|
+ nsIFrame* primaryFrame = AsContent()->GetPrimaryFrame(FlushType::Frames);
|
||||||
+ if (!primaryFrame){
|
+ if (!primaryFrame) {
|
||||||
+ return;
|
+ return aRv.ThrowNotFoundError("Node does not have a layout object");
|
||||||
+ }
|
+ }
|
||||||
+ nsRect rect;
|
+ nsRect rect;
|
||||||
+ if (x == -1 && y == -1 && w == -1 && h == -1) {
|
+ if (x == -1 && y == -1 && w == -1 && h == -1) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user