Commit 5d443229 authored by Pavel Feldman's avatar Pavel Feldman Committed by Commit Bot

Revert "InspectorDOMSnapshotAgent: expose and book layout nodes owned by...

Revert "InspectorDOMSnapshotAgent: expose and book layout nodes owned by pseudo elements under their owners."

This reverts commit 513a9fad.

Reason for revert: this resulted in a 500% increase failure rate on the downstream bots.

Original change's description:
> InspectorDOMSnapshotAgent: expose and book layout nodes owned by pseudo elements under their owners.
> 
> Currently, only support before, after and first letter pseudo types.
> 
> Change-Id: Ifb10fecad1dbfb6b987eaa0bd0e7ccb4a222d13f
> Reviewed-on: https://chromium-review.googlesource.com/1125511
> Commit-Queue: Hidy Han <hidyhan@chromium.org>
> Reviewed-by: Pavel Feldman <pfeldman@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#575785}

TBR=pfeldman@chromium.org,zoeclifford@chromium.org,hidyhan@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I3813eeb84a0f621020a90e85c7d2b75c698963b2
Reviewed-on: https://chromium-review.googlesource.com/1145440
Commit-Queue: Pavel Feldman <pfeldman@chromium.org>
Reviewed-by: default avatarPavel Feldman <pfeldman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576917}
parent 97f34880
......@@ -665,7 +665,6 @@ crbug.com/591099 idle-callback/test-runner-run-idle-tasks.html [ Crash Pass Time
crbug.com/714962 images/color-profile-background-clip-text.html [ Failure ]
crbug.com/591099 images/color-profile-image-filter-all.html [ Failure ]
crbug.com/714962 inspector-protocol/css/css-get-platform-fonts.js [ Failure ]
crbug.com/591099 inspector-protocol/dom-snapshot/dom-snapshot-getSnapshot-pseudo-element.js [ Failure ]
crbug.com/714962 inspector-protocol/dom-snapshot/dom-snapshot-getSnapshot-viewport.js [ Failure ]
crbug.com/591099 inspector-protocol/dom-snapshot/dom-snapshot-getSnapshot.js [ Failure ]
crbug.com/591099 inspector-protocol/layers/get-layers.js [ Failure ]
......
Tests DOMSnapshot.getSnapshot exports layout tree nodes associated with pseudo elements.
{
"domNodes": [
{
"nodeType": 9,
"nodeName": "#document",
"nodeValue": "",
"backendNodeId": "<number>",
"childNodeIndexes": [
1
],
"layoutNodeIndex": 0,
"documentURL": "<string>",
"baseURL": "<string>",
"documentEncoding": "windows-1252",
"frameId": "<string>"
},
{
"nodeType": 1,
"nodeName": "HTML",
"nodeValue": "",
"backendNodeId": "<number>",
"childNodeIndexes": [
2,
6
],
"layoutNodeIndex": 1,
"frameId": "<string>"
},
{
"nodeType": 1,
"nodeName": "HEAD",
"nodeValue": "",
"backendNodeId": "<number>",
"childNodeIndexes": [
3,
5
]
},
{
"nodeType": 1,
"nodeName": "STYLE",
"nodeValue": "",
"backendNodeId": "<number>",
"childNodeIndexes": [
4
]
},
{
"nodeType": 3,
"nodeName": "#text",
"nodeValue": "\n .c::first-letter { font-weight: bold; color: blue; }\n .c::before { counter-increment: square; content: 'square: ' counter(squre) url(square.png) '! '; }\n ",
"backendNodeId": "<number>"
},
{
"nodeType": 3,
"nodeName": "#text",
"nodeValue": "\n ",
"backendNodeId": "<number>"
},
{
"nodeType": 1,
"nodeName": "BODY",
"nodeValue": "",
"backendNodeId": "<number>",
"childNodeIndexes": [
7,
8,
12
],
"layoutNodeIndex": 2
},
{
"nodeType": 3,
"nodeName": "#text",
"nodeValue": "\n ",
"backendNodeId": "<number>"
},
{
"nodeType": 1,
"nodeName": "P",
"nodeValue": "",
"backendNodeId": "<number>",
"childNodeIndexes": [
11
],
"attributes": [
{
"name": "class",
"value": "c"
}
],
"pseudoElementIndexes": [
9,
10
],
"layoutNodeIndex": 3
},
{
"nodeType": 1,
"nodeName": "<pseudo:first-letter>",
"nodeValue": "",
"backendNodeId": "<number>",
"layoutNodeIndex": 4,
"pseudoType": "first-letter"
},
{
"nodeType": 1,
"nodeName": "<pseudo:before>",
"nodeValue": "",
"backendNodeId": "<number>",
"layoutNodeIndex": 6,
"pseudoType": "before"
},
{
"nodeType": 3,
"nodeName": "#text",
"nodeValue": "I have some content before me with a first letter.",
"backendNodeId": "<number>",
"layoutNodeIndex": 12
},
{
"nodeType": 3,
"nodeName": "#text",
"nodeValue": "\n \n\n",
"backendNodeId": "<number>"
}
],
"layoutTreeNodes": [
{
"domNodeIndex": 0,
"boundingBox": "<object>"
},
{
"domNodeIndex": 1,
"boundingBox": "<object>",
"styleIndex": 0
},
{
"domNodeIndex": 6,
"boundingBox": "<object>",
"styleIndex": 0
},
{
"domNodeIndex": 8,
"boundingBox": "<object>",
"styleIndex": 0
},
{
"domNodeIndex": 9,
"boundingBox": "<object>",
"styleIndex": 1
},
{
"domNodeIndex": 9,
"boundingBox": "<object>",
"layoutText": "s",
"inlineTextNodes": [
{
"boundingBox": "<object>",
"startCharacterIndex": 0,
"numCharacters": 1
}
],
"styleIndex": 1
},
{
"domNodeIndex": 10,
"boundingBox": "<object>",
"styleIndex": 0
},
{
"domNodeIndex": 10,
"boundingBox": "<object>",
"styleIndex": 0
},
{
"domNodeIndex": 10,
"boundingBox": "<object>",
"layoutText": "quare: ",
"inlineTextNodes": [
{
"boundingBox": "<object>",
"startCharacterIndex": 0,
"numCharacters": 7
}
],
"styleIndex": 0
},
{
"domNodeIndex": 10,
"boundingBox": "<object>",
"layoutText": "0",
"inlineTextNodes": [
{
"boundingBox": "<object>",
"startCharacterIndex": 0,
"numCharacters": 1
}
],
"styleIndex": 0
},
{
"domNodeIndex": 10,
"boundingBox": "<object>",
"styleIndex": 0
},
{
"domNodeIndex": 10,
"boundingBox": "<object>",
"layoutText": "! ",
"inlineTextNodes": [
{
"boundingBox": "<object>",
"startCharacterIndex": 0,
"numCharacters": 2
}
],
"styleIndex": 0
},
{
"domNodeIndex": 11,
"boundingBox": "<object>",
"layoutText": "I have some content before me with a first letter.",
"inlineTextNodes": [
{
"boundingBox": "<object>",
"startCharacterIndex": 0,
"numCharacters": 50
}
],
"styleIndex": 0
}
],
"computedStyles": [
{
"properties": [
{
"name": "font-weight",
"value": "400"
},
{
"name": "color",
"value": "rgb(0, 0, 0)"
}
]
},
{
"properties": [
{
"name": "font-weight",
"value": "700"
},
{
"name": "color",
"value": "rgb(0, 0, 255)"
}
]
}
]
}
(async function(testRunner) {
var {page, session, dp} = await testRunner.startURL('../resources/dom-snapshot-pseudo-element.html', 'Tests DOMSnapshot.getSnapshot exports layout tree nodes associated with pseudo elements.');
function stabilize(key, value) {
var unstableKeys = ['documentURL', 'baseURL', 'frameId', 'backendNodeId', 'boundingBox'];
if (unstableKeys.indexOf(key) !== -1)
return '<' + typeof(value) + '>';
return value;
}
var response = await dp.DOMSnapshot.getSnapshot({'computedStyleWhitelist': ['font-weight', 'color'], 'includeEventListeners': true});
if (response.error)
testRunner.log(response);
else
testRunner.log(JSON.stringify(response.result, stabilize, 2));
testRunner.completeTest();
})
<html>
<style>
.c::first-letter { font-weight: bold; color: blue; }
.c::before { counter-increment: square; content: 'square: ' counter(squre) url(square.png) '! '; }
</style>
<body>
<p class='c'>I have some content before me with a first letter.</p>
</body>
</html>
......@@ -361,8 +361,7 @@ int InspectorDOMSnapshotAgent::VisitNode(Node* node,
int index = dom_nodes_->length();
dom_nodes_->addItem(std::move(owned_value));
int layoutNodeIndex =
VisitLayoutTreeNode(node->GetLayoutObject(), node, index);
int layoutNodeIndex = VisitLayoutTreeNode(node, index);
if (layoutNodeIndex != -1)
value->setLayoutNodeIndex(layoutNodeIndex);
......@@ -431,12 +430,10 @@ int InspectorDOMSnapshotAgent::VisitNode(Node* node,
if (InspectorDOMAgent::GetPseudoElementType(element->GetPseudoId(),
&pseudo_type)) {
value->setPseudoType(pseudo_type);
VisitPseudoLayoutChildren(node, node->GetLayoutObject(), index);
}
} else {
value->setPseudoElementIndexes(
VisitPseudoElements(element, index, include_event_listeners,
include_user_agent_shadow_tree));
value->setPseudoElementIndexes(VisitPseudoElements(
element, include_event_listeners, include_user_agent_shadow_tree));
}
HTMLImageElement* image_element = ToHTMLImageElementOrNull(node);
......@@ -589,7 +586,7 @@ int InspectorDOMSnapshotAgent::VisitNode2(Node* node, int parent_index) {
nodes->getNodeValue(nullptr)->addItem(AddString(node_value));
nodes->getBackendNodeId(nullptr)->addItem(backend_node_id);
nodes->getAttributes(nullptr)->addItem(BuildArrayForElementAttributes2(node));
BuildLayoutTreeNode(node->GetLayoutObject(), node, index);
BuildLayoutTreeNode(node, index);
if (origin_url_map_ && origin_url_map_->Contains(backend_node_id)) {
String origin_url = origin_url_map_->at(backend_node_id);
......@@ -639,7 +636,6 @@ int InspectorDOMSnapshotAgent::VisitNode2(Node* node, int parent_index) {
if (InspectorDOMAgent::GetPseudoElementType(element->GetPseudoId(),
&pseudo_type)) {
SetRare(nodes->getPseudoType(nullptr), index, pseudo_type);
VisitPseudoLayoutChildren2(node, node->GetLayoutObject(), index);
}
} else {
VisitPseudoElements2(element, index);
......@@ -726,66 +722,45 @@ void InspectorDOMSnapshotAgent::VisitContainerChildren2(Node* container,
}
}
void InspectorDOMSnapshotAgent::VisitPseudoLayoutChildren(
Node* pseudo_node,
LayoutObject* layout_object,
int index) {
for (LayoutObject* child = layout_object->SlowFirstChild(); child;
child = child->NextSibling()) {
VisitLayoutTreeNode(child, pseudo_node, index);
}
}
void InspectorDOMSnapshotAgent::VisitPseudoLayoutChildren2(
Node* pseudo_node,
LayoutObject* layout_object,
int index) {
for (LayoutObject* child = layout_object->SlowFirstChild(); child;
child = child->NextSibling()) {
BuildLayoutTreeNode(child, pseudo_node, index);
}
}
std::unique_ptr<protocol::Array<int>>
InspectorDOMSnapshotAgent::VisitPseudoElements(
Element* parent,
int index,
bool include_event_listeners,
bool include_user_agent_shadow_tree) {
if (!parent->GetPseudoElement(kPseudoIdFirstLetter) &&
!parent->GetPseudoElement(kPseudoIdBefore) &&
if (!parent->GetPseudoElement(kPseudoIdBefore) &&
!parent->GetPseudoElement(kPseudoIdAfter)) {
return nullptr;
}
auto pseudo_elements = protocol::Array<int>::create();
PseudoId pseudo_types[] = {kPseudoIdFirstLetter, kPseudoIdBefore,
kPseudoIdAfter};
for (PseudoId pseudo_id : pseudo_types) {
if (parent->GetPseudoElement(pseudo_id)) {
Node* pseudo_node = parent->GetPseudoElement(pseudo_id);
pseudo_elements->addItem(VisitNode(pseudo_node, include_event_listeners,
include_user_agent_shadow_tree));
}
if (parent->GetPseudoElement(kPseudoIdBefore)) {
pseudo_elements->addItem(
VisitNode(parent->GetPseudoElement(kPseudoIdBefore),
include_event_listeners, include_user_agent_shadow_tree));
}
if (parent->GetPseudoElement(kPseudoIdAfter)) {
pseudo_elements->addItem(VisitNode(parent->GetPseudoElement(kPseudoIdAfter),
include_event_listeners,
include_user_agent_shadow_tree));
}
return pseudo_elements;
}
void InspectorDOMSnapshotAgent::VisitPseudoElements2(Element* parent,
int parent_index) {
if (!parent->GetPseudoElement(kPseudoIdFirstLetter) &&
!parent->GetPseudoElement(kPseudoIdBefore) &&
if (!parent->GetPseudoElement(kPseudoIdBefore) &&
!parent->GetPseudoElement(kPseudoIdAfter)) {
return;
}
PseudoId pseudo_types[] = {kPseudoIdFirstLetter, kPseudoIdBefore,
kPseudoIdAfter};
for (PseudoId i : pseudo_types) {
if (parent->GetPseudoElement(i)) {
Node* pseudo_node = parent->GetPseudoElement(i);
VisitNode2(pseudo_node, parent_index);
}
}
auto pseudo_elements = protocol::Array<int>::create();
if (parent->GetPseudoElement(kPseudoIdBefore))
VisitNode2(parent->GetPseudoElement(kPseudoIdBefore), parent_index);
if (parent->GetPseudoElement(kPseudoIdAfter))
VisitNode2(parent->GetPseudoElement(kPseudoIdAfter), parent_index);
}
std::unique_ptr<protocol::Array<protocol::DOMSnapshot::NameValue>>
......@@ -817,9 +792,8 @@ InspectorDOMSnapshotAgent::BuildArrayForElementAttributes2(Node* node) {
return result;
}
int InspectorDOMSnapshotAgent::VisitLayoutTreeNode(LayoutObject* layout_object,
Node* node,
int node_index) {
int InspectorDOMSnapshotAgent::VisitLayoutTreeNode(Node* node, int node_index) {
LayoutObject* layout_object = node->GetLayoutObject();
if (!layout_object)
return -1;
......@@ -872,9 +846,8 @@ int InspectorDOMSnapshotAgent::VisitLayoutTreeNode(LayoutObject* layout_object,
return index;
}
int InspectorDOMSnapshotAgent::BuildLayoutTreeNode(LayoutObject* layout_object,
Node* node,
int node_index) {
int InspectorDOMSnapshotAgent::BuildLayoutTreeNode(Node* node, int node_index) {
LayoutObject* layout_object = node->GetLayoutObject();
if (!layout_object)
return -1;
auto* layout_tree_snapshot = document_->getLayout();
......
......@@ -93,18 +93,8 @@ class CORE_EXPORT InspectorDOMSnapshotAgent final
bool include_event_listeners,
bool include_user_agent_shadow_tree);
void VisitContainerChildren2(Node* container, int parent_index);
// Collect LayoutTreeNodes owned by a pseudo element.
void VisitPseudoLayoutChildren(Node* pseudo_node,
LayoutObject* layout_object,
int index);
void VisitPseudoLayoutChildren2(Node* pseudo_node,
LayoutObject* layout_object,
int index);
std::unique_ptr<protocol::Array<int>> VisitPseudoElements(
Element* parent,
int index,
bool include_event_listeners,
bool include_user_agent_shadow_tree);
void VisitPseudoElements2(Element* parent, int parent_index);
......@@ -112,11 +102,11 @@ class CORE_EXPORT InspectorDOMSnapshotAgent final
BuildArrayForElementAttributes(Element*);
std::unique_ptr<protocol::Array<int>> BuildArrayForElementAttributes2(Node*);
// Adds a LayoutTreeNode for the LayoutObject to |layout_tree_nodes_| and
// returns its index. Returns -1 if the Node has no associated LayoutObject.
// Associates LayoutObjects under a pseudo element with the element.
int VisitLayoutTreeNode(LayoutObject*, Node*, int node_index);
int BuildLayoutTreeNode(LayoutObject*, Node*, int node_index);
// Adds a LayoutTreeNode for the LayoutObject of the given Node to
// |layout_tree_nodes_| and returns its index. Returns -1 if the Node has no
// associated LayoutObject.
int VisitLayoutTreeNode(Node*, int node_index);
int BuildLayoutTreeNode(Node*, int node_index);
// Returns the index of the ComputedStyle in |computed_styles_| for the given
// Node. Adds a new ComputedStyle if necessary, but ensures no duplicates are
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment