Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: Source/devtools/front_end/sdk/DOMModel.js

Issue 720793003: DevTools: Replace visibleChildrenCount with hasVisibleChildren in ElementsTreeOutline. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/devtools/front_end/elements/ElementsTreeOutline.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved.
3 * Copyright (C) 2009 Joseph Pecoraro 3 * Copyright (C) 2009 Joseph Pecoraro
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 pseudoType: function() 222 pseudoType: function()
223 { 223 {
224 return this._pseudoType; 224 return this._pseudoType;
225 }, 225 },
226 226
227 /** 227 /**
228 * @return {boolean} 228 * @return {boolean}
229 */ 229 */
230 hasPseudoElements: function() 230 hasPseudoElements: function()
231 { 231 {
232 return Object.keys(this._pseudoElements).length !== 0; 232 return this._pseudoElements.size > 0;
233 }, 233 },
234 234
235 /** 235 /**
236 * @return {!Object.<string, !WebInspector.DOMNode>} 236 * @return {!Map<string, !WebInspector.DOMNode>}
237 */ 237 */
238 pseudoElements: function() 238 pseudoElements: function()
239 { 239 {
240 return this._pseudoElements; 240 return this._pseudoElements;
241 }, 241 },
242 242
243 /** 243 /**
244 * @return {?WebInspector.DOMNode}
245 */
246 beforePseudoElement: function()
247 {
248 if (!this._pseudoElements)
249 return null;
250 return this._pseudoElements.get(WebInspector.DOMNode.PseudoElementNames. Before);
251 },
252
253 /**
254 * @return {?WebInspector.DOMNode}
255 */
256 afterPseudoElement: function()
257 {
258 if (!this._pseudoElements)
259 return null;
260 return this._pseudoElements.get(WebInspector.DOMNode.PseudoElementNames. After);
261 },
262
263 /**
244 * @return {boolean} 264 * @return {boolean}
245 */ 265 */
246 isInShadowTree: function() 266 isInShadowTree: function()
247 { 267 {
248 return this._isInShadowTree; 268 return this._isInShadowTree;
249 }, 269 },
250 270
251 /** 271 /**
252 * @return {?WebInspector.DOMNode} 272 * @return {?WebInspector.DOMNode}
253 */ 273 */
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 this._renumber(); 616 this._renumber();
597 return node; 617 return node;
598 }, 618 },
599 619
600 /** 620 /**
601 * @param {!WebInspector.DOMNode} node 621 * @param {!WebInspector.DOMNode} node
602 */ 622 */
603 _removeChild: function(node) 623 _removeChild: function(node)
604 { 624 {
605 if (node.pseudoType()) { 625 if (node.pseudoType()) {
606 delete this._pseudoElements[node.pseudoType()]; 626 this._pseudoElements.delete(node.pseudoType());
607 } else { 627 } else {
608 var shadowRootIndex = this._shadowRoots.indexOf(node); 628 var shadowRootIndex = this._shadowRoots.indexOf(node);
609 if (shadowRootIndex !== -1) 629 if (shadowRootIndex !== -1)
610 this._shadowRoots.splice(shadowRootIndex, 1); 630 this._shadowRoots.splice(shadowRootIndex, 1);
611 else 631 else
612 this._children.splice(this._children.indexOf(node), 1); 632 this._children.splice(this._children.indexOf(node), 1);
613 } 633 }
614 node.parentNode = null; 634 node.parentNode = null;
615 node._updateChildUserPropertyCountsOnRemoval(this); 635 node._updateChildUserPropertyCountsOnRemoval(this);
616 this._renumber(); 636 this._renumber();
(...skipping 15 matching lines...) Expand all
632 this._children.push(node); 652 this._children.push(node);
633 } 653 }
634 this._renumber(); 654 this._renumber();
635 }, 655 },
636 656
637 /** 657 /**
638 * @param {!Array.<!DOMAgent.Node>|undefined} payloads 658 * @param {!Array.<!DOMAgent.Node>|undefined} payloads
639 */ 659 */
640 _setPseudoElements: function(payloads) 660 _setPseudoElements: function(payloads)
641 { 661 {
642 this._pseudoElements = {}; 662 this._pseudoElements = new Map();
643 if (!payloads) 663 if (!payloads)
644 return; 664 return;
645 665
646 for (var i = 0; i < payloads.length; ++i) { 666 for (var i = 0; i < payloads.length; ++i) {
647 var node = new WebInspector.DOMNode(this._domModel, this.ownerDocume nt, this._isInShadowTree, payloads[i]); 667 var node = new WebInspector.DOMNode(this._domModel, this.ownerDocume nt, this._isInShadowTree, payloads[i]);
648 node.parentNode = this; 668 node.parentNode = this;
649 this._pseudoElements[node.pseudoType()] = node; 669 this._pseudoElements.set(node.pseudoType(), node);
650 } 670 }
651 }, 671 },
652 672
653 _renumber: function() 673 _renumber: function()
654 { 674 {
655 this._childNodeCount = this._children.length; 675 this._childNodeCount = this._children.length;
656 if (this._childNodeCount == 0) { 676 if (this._childNodeCount == 0) {
657 this.firstChild = null; 677 this.firstChild = null;
658 this.lastChild = null; 678 this.lastChild = null;
659 return; 679 return;
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 * @param {!DOMAgent.Node} pseudoElement 1333 * @param {!DOMAgent.Node} pseudoElement
1314 */ 1334 */
1315 _pseudoElementAdded: function(parentId, pseudoElement) 1335 _pseudoElementAdded: function(parentId, pseudoElement)
1316 { 1336 {
1317 var parent = this._idToDOMNode[parentId]; 1337 var parent = this._idToDOMNode[parentId];
1318 if (!parent) 1338 if (!parent)
1319 return; 1339 return;
1320 var node = new WebInspector.DOMNode(this, parent.ownerDocument, false, p seudoElement); 1340 var node = new WebInspector.DOMNode(this, parent.ownerDocument, false, p seudoElement);
1321 node.parentNode = parent; 1341 node.parentNode = parent;
1322 this._idToDOMNode[node.id] = node; 1342 this._idToDOMNode[node.id] = node;
1323 console.assert(!parent._pseudoElements[node.pseudoType()]); 1343 console.assert(!parent._pseudoElements.get(node.pseudoType()));
1324 parent._pseudoElements[node.pseudoType()] = node; 1344 parent._pseudoElements.set(node.pseudoType(), node);
1325 this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeInserted, node); 1345 this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeInserted, node);
1326 }, 1346 },
1327 1347
1328 /** 1348 /**
1329 * @param {!DOMAgent.NodeId} parentId 1349 * @param {!DOMAgent.NodeId} parentId
1330 * @param {!DOMAgent.NodeId} pseudoElementId 1350 * @param {!DOMAgent.NodeId} pseudoElementId
1331 */ 1351 */
1332 _pseudoElementRemoved: function(parentId, pseudoElementId) 1352 _pseudoElementRemoved: function(parentId, pseudoElementId)
1333 { 1353 {
1334 var parent = this._idToDOMNode[parentId]; 1354 var parent = this._idToDOMNode[parentId];
(...skipping 11 matching lines...) Expand all
1346 * @param {!WebInspector.DOMNode} node 1366 * @param {!WebInspector.DOMNode} node
1347 */ 1367 */
1348 _unbind: function(node) 1368 _unbind: function(node)
1349 { 1369 {
1350 delete this._idToDOMNode[node.id]; 1370 delete this._idToDOMNode[node.id];
1351 for (var i = 0; node._children && i < node._children.length; ++i) 1371 for (var i = 0; node._children && i < node._children.length; ++i)
1352 this._unbind(node._children[i]); 1372 this._unbind(node._children[i]);
1353 for (var i = 0; i < node._shadowRoots.length; ++i) 1373 for (var i = 0; i < node._shadowRoots.length; ++i)
1354 this._unbind(node._shadowRoots[i]); 1374 this._unbind(node._shadowRoots[i]);
1355 var pseudoElements = node.pseudoElements(); 1375 var pseudoElements = node.pseudoElements();
1356 for (var id in pseudoElements) 1376 for (var pseudoType of pseudoElements.keys())
1357 this._unbind(pseudoElements[id]); 1377 this._unbind(pseudoElements.get(pseudoType));
1358 if (node._templateContent) 1378 if (node._templateContent)
1359 this._unbind(node._templateContent); 1379 this._unbind(node._templateContent);
1360 }, 1380 },
1361 1381
1362 /** 1382 /**
1363 * @param {!DOMAgent.NodeId} nodeId 1383 * @param {!DOMAgent.NodeId} nodeId
1364 */ 1384 */
1365 _inspectNodeRequested: function(nodeId) 1385 _inspectNodeRequested: function(nodeId)
1366 { 1386 {
1367 this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeInspected , this.nodeForId(nodeId)); 1387 this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeInspected , this.nodeForId(nodeId));
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
1970 * @param {boolean} inspectUAShadowDOM 1990 * @param {boolean} inspectUAShadowDOM
1971 * @param {!DOMAgent.HighlightConfig} config 1991 * @param {!DOMAgent.HighlightConfig} config
1972 * @param {function(?Protocol.Error)=} callback 1992 * @param {function(?Protocol.Error)=} callback
1973 */ 1993 */
1974 setInspectModeEnabled: function(enabled, inspectUAShadowDOM, config, callbac k) 1994 setInspectModeEnabled: function(enabled, inspectUAShadowDOM, config, callbac k)
1975 { 1995 {
1976 WebInspector.overridesSupport.setTouchEmulationSuspended(enabled); 1996 WebInspector.overridesSupport.setTouchEmulationSuspended(enabled);
1977 this._agent.setInspectModeEnabled(enabled, inspectUAShadowDOM, config, c allback); 1997 this._agent.setInspectModeEnabled(enabled, inspectUAShadowDOM, config, c allback);
1978 } 1998 }
1979 } 1999 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/elements/ElementsTreeOutline.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698