Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #14561 from debajyotide/dde/enableDOMAgent
Browse files Browse the repository at this point in the history
Enable DOMAgent in live preview
  • Loading branch information
vickramdhawal authored Oct 10, 2018
2 parents df77911 + 8614719 commit 57e8d3d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/LiveDevelopment/Agents/CSSAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,19 @@ define(function CSSAgent(require, exports, module) {
return _styleSheetDetails[styleSheetId] && _styleSheetDetails[styleSheetId].canonicalizedURL;
}

/**
* Returns styleSheetDetails object
*/
function getStyleSheetDetails() {
return _styleSheetDetails;
}

EventDispatcher.makeEventDispatcher(exports);

// Export public functions
exports.enable = enable;
exports.styleForURL = styleForURL;
exports.getStyleSheetDetails = getStyleSheetDetails;
exports.getURLForStyleSheetId = getURLForStyleSheetId;
exports.reloadCSSForDocument = reloadCSSForDocument;
exports.clearCSSForDocument = clearCSSForDocument;
Expand Down
6 changes: 6 additions & 0 deletions src/LiveDevelopment/Agents/DOMAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ define(function DOMAgent(require, exports, module) {
function _onLoadEventFired(event, res) {
// res = {timestamp}
Inspector.DOM.getDocument(function onGetDocument(res) {
exports.document = res;
exports.trigger("getDocument", res);
// res = {root}
_idToNode = {};
Expand Down Expand Up @@ -318,6 +319,10 @@ define(function DOMAgent(require, exports, module) {
Inspector.DOM.off(".DOMAgent");
}

/** Return id to DOM Node mapping object */
function getIdToNodeMap() {
return _idToNode;
}

EventDispatcher.makeEventDispatcher(exports);

Expand All @@ -334,4 +339,5 @@ define(function DOMAgent(require, exports, module) {
exports.applyChange = applyChange;
exports.load = load;
exports.unload = unload;
exports.getIdToNodeMap = getIdToNodeMap;
});
24 changes: 24 additions & 0 deletions src/LiveDevelopment/Agents/DOMNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ define(function DOMNodeModule(require, exports, module) {
} else if (payload.childNodeCount) {
this.agent.requestChildNodes(this);
}

this._setPseudoElements(payload.pseudoElements);
};

/** Create child nodes from the given payload
Expand All @@ -160,6 +162,28 @@ define(function DOMNodeModule(require, exports, module) {
}
};

/** Create pseudoElements child nodes from the given payload
* @param [[DOM.Node]] payload of pseudoElements
*/
DOMNode.prototype._setPseudoElements = function _setPseudoElements(pseudoElementsPayload) {
this._pseudoElements = {};
if (!pseudoElementsPayload) {
return;
}
var i, payload, node;
for (i in pseudoElementsPayload) {
payload = pseudoElementsPayload[i];
node = new DOMNode(this.agent, payload);
node.parent = this;
this._pseudoElements[payload.pseudoType] = node;
}
};

/** Get pseudo elements of a node */
DOMNode.prototype.pseudoElements = function pseudoElements() {
return this._pseudoElements;
};

/** Construct the payload for this node */
DOMNode.prototype.payload = function payload() {
var res = { type: this.type };
Expand Down
1 change: 1 addition & 0 deletions src/LiveDevelopment/LiveDevelopment.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ define(function LiveDevelopment(require, exports, module) {
"remote" : true,
"network" : true,
"css" : true,
"dom" : true,
"highlight" : true
};

Expand Down

0 comments on commit 57e8d3d

Please sign in to comment.