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

Side by Side Diff: webkit/glue/devtools/js/dom_agent.js

Issue 60047: DevTools: Add support for r/o CSS inspection. Original review CL by serya : h... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 months 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Dom and DomNode are used to represent remote DOM in the 6 * @fileoverview Dom and DomNode are used to represent remote DOM in the
7 * web inspector. 7 * web inspector.
8 */ 8 */
9 goog.provide('devtools.DomAgent'); 9 goog.provide('devtools.DomAgent');
10 goog.provide('devtools.DomDocument'); 10 goog.provide('devtools.DomDocument');
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 49 }
50 50
51 this.childNodesCount_ = payload[devtools.PayloadIndex.HAS_CHILDREN]; 51 this.childNodesCount_ = payload[devtools.PayloadIndex.HAS_CHILDREN];
52 this.children = null; 52 this.children = null;
53 53
54 this.nextSibling = null; 54 this.nextSibling = null;
55 this.prevSibling = null; 55 this.prevSibling = null;
56 this.firstChild = null; 56 this.firstChild = null;
57 this.parentNode = null; 57 this.parentNode = null;
58 58
59 this.styles_ = null;
60 this.disabledStyleProperties_ = {};
61
59 if (payload.length > devtools.PayloadIndex.CHILD_NODES) { 62 if (payload.length > devtools.PayloadIndex.CHILD_NODES) {
60 // Has children payloads 63 // Has children payloads
61 this.setChildrenPayload_( 64 this.setChildrenPayload_(
62 payload[devtools.PayloadIndex.CHILD_NODES]); 65 payload[devtools.PayloadIndex.CHILD_NODES]);
63 } 66 }
64 }; 67 };
65 68
66 69
67 /** 70 /**
68 * Overrides for getters and setters. 71 * Overrides for getters and setters.
(...skipping 17 matching lines...) Expand all
86 }; 89 };
87 90
88 91
89 /** 92 /**
90 * Sets attributes for a given node based on a given attrs payload. 93 * Sets attributes for a given node based on a given attrs payload.
91 * @param {Array.<string>} attrs Attribute key-value pairs to set. 94 * @param {Array.<string>} attrs Attribute key-value pairs to set.
92 * @private 95 * @private
93 */ 96 */
94 devtools.DomNode.prototype.setAttributesPayload_ = function(attrs) { 97 devtools.DomNode.prototype.setAttributesPayload_ = function(attrs) {
95 for (var i = 0; i < attrs.length; i += 2) { 98 for (var i = 0; i < attrs.length; i += 2) {
96 var attr = {"name" : attrs[i], "value" : attrs[i+1]}; 99 this.addAttribute_(attrs[i], attrs[i + 1]);
97 this.attributes.push(attr);
98 this.attributesMap_[attrs[i]] = attr;
99 } 100 }
100 }; 101 };
101 102
102 103
103 /** 104 /**
104 * @return True iff node has attributes. 105 * @return True iff node has attributes.
105 */ 106 */
106 devtools.DomNode.prototype.hasAttributes = function() { 107 devtools.DomNode.prototype.hasAttributes = function() {
107 return this.attributes.length > 0; 108 return this.attributes.length > 0;
108 }; 109 };
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 * @param {string} value Attribute value to set. 202 * @param {string} value Attribute value to set.
202 */ 203 */
203 devtools.DomNode.prototype.setAttribute = function(name, value) { 204 devtools.DomNode.prototype.setAttribute = function(name, value) {
204 var self = this; 205 var self = this;
205 this.ownerDocument.domAgent_.setAttributeAsync(this, name, value, 206 this.ownerDocument.domAgent_.setAttributeAsync(this, name, value,
206 function() { 207 function() {
207 var attr = self.attributesMap_[name]; 208 var attr = self.attributesMap_[name];
208 if (attr) { 209 if (attr) {
209 attr.value = value; 210 attr.value = value;
210 } else { 211 } else {
211 attr = {"name" : name, "value" : value}; 212 attr = self.addAttribute_(name, value);
212 self.attributesMap_[name] = attr;
213 self.attributes_.push(attr);
214 } 213 }
215 }); 214 });
216 }; 215 };
217 216
217 /**
218 * Creates an attribute-like object and adds it to the object.
219 * @param {string} name Attribute name to set value for.
220 * @param {string} value Attribute value to set.
221 */
222 devtools.DomNode.prototype.addAttribute_ = function(name, value) {
223 var attr = {
224 "name": name,
225 "value": value,
226 node_: this,
227 /* Must be called after node.setStyles_. */
228 get style() {
229 return this.node_.styles_.attributes[this.name];
230 }
231 };
232
233 this.attributesMap_[name] = attr;
234 this.attributes.push(attr);
235 };
236
218 237
219 /** 238 /**
220 * Sends 'remove attribute' command to the remote agent. 239 * Sends 'remove attribute' command to the remote agent.
221 * @param {string} name Attribute name to set value for. 240 * @param {string} name Attribute name to set value for.
222 */ 241 */
223 devtools.DomNode.prototype.removeAttribute = function(name) { 242 devtools.DomNode.prototype.removeAttribute = function(name) {
224 var self = this; 243 var self = this;
225 this.ownerDocument.domAgent_.removeAttributeAsync(this, name, function() { 244 this.ownerDocument.domAgent_.removeAttributeAsync(this, name, function() {
226 delete self.attributesMap_[name]; 245 delete self.attributesMap_[name];
227 for (var i = 0; i < self.attributes.length; ++i) { 246 for (var i = 0; i < self.attributes.length; ++i) {
228 if (self.attributes[i].name == name) { 247 if (self.attributes[i].name == name) {
229 self.attributes.splice(i, 1); 248 self.attributes.splice(i, 1);
230 break; 249 break;
231 } 250 }
232 } 251 }
233 }); 252 });
234 }; 253 };
235 254
236 255
237 /** 256 /**
257 * Returns inline style (if styles has loaded). Must be called after
258 * node.setStyles_.
259 */
260 devtools.DomNode.prototype.__defineGetter__("style", function() {
261 return this.styles_.inlineStyle;
262 });
263
264
265
266 /**
267 * Makes available the following methods and properties:
268 * - node.style property
269 * - node.document.defaultView.getComputedStyles(node)
270 * - node.document.defaultView.getMatchedCSSRules(node, ...)
271 * - style attribute of node's attributes
272 * @param {string} computedStyle is a cssText of result of getComputedStyle().
273 * @param {string} inlineStyle is a style.cssText (defined in the STYLE
274 * attribute).
275 * @param {Object} styleAttributes represents 'style' property
276 * of attributes.
277 * @param {Array.<object>} matchedCSSRules represents result of the
278 * getMatchedCSSRules(node, "", authorOnly). Each elemet consists of:
279 * selector, rule.style.cssText[, rule.parentStyleSheet.href
280 * [, rule.parentStyleSheet.ownerNode.nodeName]].
281 */
282 devtools.DomNode.prototype.setStyles_ = function(computedStyle, inlineStyle,
283 styleAttributes, matchedCSSRules) {
284 var styles = {};
285 styles.computedStyle = this.parseCSSText_(computedStyle, "computed");
286 styles.inlineStyle = this.parseCSSText_(inlineStyle, "inline");
287
288 styles.attributes = {};
289 for (var name in styleAttributes) {
290 var style = this.parseCSSText_(styleAttributes[name], "@" + name);
291 styles.attributes[name] = style;
292 }
293
294 styles.matchedCSSRules = [];
295 for (var i = 0; i < matchedCSSRules.length; i++) {
296 var descr = matchedCSSRules[i];
297 var selector = descr.selector;
298 var style = this.parseCSSText_(descr.cssText, "CSSRule#" + selector);
299
300 var parentStyleSheet = undefined;
301 if (descr.parentStyleSheetHref) {
302 parentStyleSheet = {href: descr.parentStyleSheetHref};
303
304 if (descr.parentStyleSheetOwnerNodeName) {
305 parentStyleSheet.ownerNode =
306 {nodeName: descr.parentStyleSheetOwnerNodeName};
307 }
308 }
309
310 styles.matchedCSSRules.push({selectorText: selector, "style": style,
311 "parentStyleSheet": parentStyleSheet});
312 }
313
314 this.styles_ = styles;
315 }
316
317
318 /**
319 * Creates a style object from the cssText.
320 * Since the StyleSidebarPane implies the
321 * style object lives as long as the node itself and stores data in
322 * __disabledPropertyPriorities this methods adds a getter which stores the
323 * data in the devtools.DomNode object.
324 * @param {string} cssText
325 * @param {string} styleId is used to distinguish associated part of
326 * __disabledPropertyPriorities with the style object.
327 * @return {CSSStyleDescription}
328 */
329 devtools.DomNode.prototype.parseCSSText_ = function(cssText, styleId) {
330 // There is no way to create CSSStyleDeclaration without creating a
331 // dummy element. In real DOM CSSStyleDeclaration has several
332 // implementations (for instance CSSComputedStyleDeclaration) and
333 // current method does not covers diffirences in behaviour.
334 // TODO (serya): correclty implement all types of CSSStyleDeclaration,
335 // avoid creation a lot of dummy nodes.
336
337 var style = document.createElement("SPAN").style;
338 style.cssText = cssText;
339
340 var props = this.disabledStyleProperties_[styleId] || {};
341 this.disabledStyleProperties_[styleId] = props;
342 style.__disabledPropertyPriorities = props;
343
344 return style;
345 }
346
347
348 /**
349 * Remove references to the style information to release
350 * resources when styles are not going to be used.
351 * @see setStyles_.
352 */
353 devtools.DomNode.prototype.clearStyles_ = function() {
354 this.styles_ = null;
355 }
356
357
358 /**
238 * Remote Dom document abstraction. 359 * Remote Dom document abstraction.
239 * @param {devtools.DomAgent} domAgent owner agent. 360 * @param {devtools.DomAgent} domAgent owner agent.
361 * @param {devtools.DomWindow} defaultView owner window.
240 * @constructor. 362 * @constructor.
241 */ 363 */
242 devtools.DomDocument = function(domAgent) { 364 devtools.DomDocument = function(domAgent, defaultView) {
243 devtools.DomNode.call(this, null, 365 devtools.DomNode.call(this, null,
244 [ 366 [
245 0, // id 367 0, // id
246 9, // type = Node.DOCUMENT_NODE, 368 9, // type = Node.DOCUMENT_NODE,
247 "", // nodeName 369 "", // nodeName
248 "", // nodeValue 370 "", // nodeValue
249 [], // attributes 371 [], // attributes
250 0, // childNodeCount 372 0, // childNodeCount
251 ]); 373 ]);
252 this.listeners_ = {}; 374 this.listeners_ = {};
253 this.defaultView = {
254 getComputedStyle : function() {},
255 getMatchedCSSRules : function() {}
256 };
257 this.domAgent_ = domAgent; 375 this.domAgent_ = domAgent;
376 this.defaultView = defaultView;
258 }; 377 };
259 goog.inherits(devtools.DomDocument, devtools.DomNode); 378 goog.inherits(devtools.DomDocument, devtools.DomNode);
260 379
261 380
262 /** 381 /**
263 * Adds event listener to the Dom. 382 * Adds event listener to the Dom.
264 * @param {string} name Event name. 383 * @param {string} name Event name.
265 * @param {function(Event):undefined} callback Listener callback. 384 * @param {function(Event):undefined} callback Listener callback.
266 * @param {bool} useCapture Listener's useCapture settings. 385 * @param {bool} useCapture Listener's useCapture settings.
267 */ 386 */
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 var listeners = this.listeners_[name]; 424 var listeners = this.listeners_[name];
306 if (!listeners) { 425 if (!listeners) {
307 return; 426 return;
308 } 427 }
309 for (var i = 0; i < listeners.length; ++i) { 428 for (var i = 0; i < listeners.length; ++i) {
310 listeners[i](event); 429 listeners[i](event);
311 } 430 }
312 }; 431 };
313 432
314 433
434
435 /**
436 * Simulation of inspected DOMWindow.
437 * @param {devtools.DomAgent} domAgent owner agent.
438 * @constructor
439 */
440 devtools.DomWindow = function(domAgent) {
441 this.document = new devtools.DomDocument(domAgent, this);
442 };
443
444 /**
445 * Represents DOM Node class.
446 */
447 devtools.DomWindow.prototype.__defineGetter__("Node", function() {
448 return devtools.DomNode;
449 });
450
451 /**
452 * Represents DOM Element class.
453 * @constructor
454 */
455 devtools.DomWindow.prototype.__defineGetter__("Element", function() {
456 return devtools.DomNode;
457 });
458
459
460 /**
461 * See usages in ScopeChainSidebarPane.js where it's called as
462 * constructor.
463 */
464 devtools.DomWindow.prototype.Object = function() {
465 };
466
467
468 /**
469 * Simulates the DOM interface for styles. Must be called after
470 * node.setStyles_.
471 * @param {devtools.DomNode} node
472 * @return {CSSStyleDescription}
473 */
474 devtools.DomWindow.prototype.getComputedStyle = function(node) {
475 return node.styles_.computedStyle;
476 };
477
478
479 /**
480 * Simulates the DOM interface for styles. Must be called after
481 * node.setStyles_.
482 * @param {devtools.DomNode} nodeStyles
483 * @param {string} pseudoElement assumed to be empty string.
484 * @param {boolean} authorOnly assumed to be equal to authorOnly argument of
485 * getNodeStylesAsync.
486 * @return {CSSStyleDescription}
487 */
488 devtools.DomWindow.prototype.getMatchedCSSRules = function(node,
489 pseudoElement, authorOnly) {
490 return node.styles_.matchedCSSRules;
491 };
492
493
315 /** 494 /**
316 * Creates DomAgent Js representation. 495 * Creates DomAgent Js representation.
317 * @constructor 496 * @constructor
318 */ 497 */
319 devtools.DomAgent = function() { 498 devtools.DomAgent = function() {
320 RemoteDomAgent.DidGetChildNodes = 499 RemoteDomAgent.DidGetChildNodes =
321 devtools.Callback.processCallback; 500 devtools.Callback.processCallback;
322 RemoteDomAgent.DidPerformSearch = 501 RemoteDomAgent.DidPerformSearch =
323 devtools.Callback.processCallback; 502 devtools.Callback.processCallback;
324 RemoteDomAgent.DidApplyDomChange = 503 RemoteDomAgent.DidApplyDomChange =
325 devtools.Callback.processCallback; 504 devtools.Callback.processCallback;
505 RemoteDomAgent.DidGetNodeStyles =
506 devtools.Callback.processCallback;
326 RemoteDomAgent.DidRemoveAttribute = 507 RemoteDomAgent.DidRemoveAttribute =
327 devtools.Callback.processCallback; 508 devtools.Callback.processCallback;
328 RemoteDomAgent.DidSetTextNodeValue = 509 RemoteDomAgent.DidSetTextNodeValue =
329 devtools.Callback.processCallback; 510 devtools.Callback.processCallback;
330 RemoteDomAgent.AttributesUpdated = 511 RemoteDomAgent.AttributesUpdated =
331 goog.bind(this.attributesUpdated, this); 512 goog.bind(this.attributesUpdated, this);
332 RemoteDomAgent.SetDocumentElement = 513 RemoteDomAgent.SetDocumentElement =
333 goog.bind(this.setDocumentElement, this); 514 goog.bind(this.setDocumentElement, this);
334 RemoteDomAgent.SetChildNodes = 515 RemoteDomAgent.SetChildNodes =
335 goog.bind(this.setChildNodes, this); 516 goog.bind(this.setChildNodes, this);
336 RemoteDomAgent.HasChildrenUpdated = 517 RemoteDomAgent.HasChildrenUpdated =
337 goog.bind(this.hasChildrenUpdated, this); 518 goog.bind(this.hasChildrenUpdated, this);
338 RemoteDomAgent.ChildNodeInserted = 519 RemoteDomAgent.ChildNodeInserted =
339 goog.bind(this.childNodeInserted, this); 520 goog.bind(this.childNodeInserted, this);
340 RemoteDomAgent.ChildNodeRemoved = 521 RemoteDomAgent.ChildNodeRemoved =
341 goog.bind(this.childNodeRemoved, this); 522 goog.bind(this.childNodeRemoved, this);
342 523
343 /** 524 /**
344 * Top-level (and the only) document. 525 * Top-level (and the only) document.
345 * @type {devtools.DomDocument} 526 * @type {devtools.DomWindow}
346 * @private 527 * @private
347 */ 528 */
348 this.document_ = null; 529 this.window_ = null;
349 530
350 /** 531 /**
351 * Id to node mapping. 532 * Id to node mapping.
352 * @type {Object} 533 * @type {Object}
353 * @private 534 * @private
354 */ 535 */
355 this.idToDomNode_ = null; 536 this.idToDomNode_ = null;
356 537
357 /** 538 /**
358 * @type {Array.<number>} Node ids for search results. 539 * @type {Array.<number>} Node ids for search results.
359 * @private 540 * @private
360 */ 541 */
361 this.searchResults_ = null; 542 this.searchResults_ = null;
362 543
363 this.reset(); 544 this.reset();
364 }; 545 };
365 546
366 547
367 /** 548 /**
368 * Rests dom agent to its initial state. 549 * Rests dom agent to its initial state.
369 */ 550 */
370 devtools.DomAgent.prototype.reset = function() { 551 devtools.DomAgent.prototype.reset = function() {
371 this.document_ = new devtools.DomDocument(this); 552 this.window_ = new devtools.DomWindow(this);
372 this.idToDomNode_ = { 0 : this.document_ }; 553 this.idToDomNode_ = { 0 : this.getDocument() };
373 this.searchResults_ = []; 554 this.searchResults_ = [];
374 }; 555 };
375 556
376 557
377 /** 558 /**
378 * @return {devtools.DomDocument} Top level (and the only) document. 559 * @return {devtools.DomWindow} Window for the top level (and the only) document .
379 */ 560 */
380 devtools.DomAgent.prototype.getDocument = function() { 561 devtools.DomAgent.prototype.getWindow = function() {
381 return this.document_; 562 return this.window_;
382 }; 563 };
383 564
384 565
566 /**
567 * @return {devtools.DomDocument} A document of the top level window.
568 */
569 devtools.DomAgent.prototype.getDocument = function() {
570 return this.window_.document;
571 };
572
573
385 /** 574 /**
386 * Requests that the document element is sent from the agent. 575 * Requests that the document element is sent from the agent.
387 */ 576 */
388 devtools.DomAgent.prototype.getDocumentElementAsync = function() { 577 devtools.DomAgent.prototype.getDocumentElementAsync = function() {
389 if (this.document_.documentElement) { 578 if (this.getDocument().documentElement) {
390 return; 579 return;
391 } 580 }
392 RemoteDomAgent.GetDocumentElement(); 581 RemoteDomAgent.GetDocumentElement();
393 }; 582 };
394 583
395 584
396 /** 585 /**
397 * Asynchronously fetches children from the element with given id. 586 * Asynchronously fetches children from the element with given id.
398 * @param {devtools.DomNode} parent Element to get children for. 587 * @param {devtools.DomNode} parent Element to get children for.
399 * @param {function(devtools.DomNode):undefined} opt_callback Callback with 588 * @param {function(devtools.DomNode):undefined} opt_callback Callback with
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 devtools.DomAgent.prototype.getNodeForId = function(nodeId) { 685 devtools.DomAgent.prototype.getNodeForId = function(nodeId) {
497 return this.idToDomNode_[nodeId]; 686 return this.idToDomNode_[nodeId];
498 }; 687 };
499 688
500 689
501 /** 690 /**
502 * @see DomAgentDelegate. 691 * @see DomAgentDelegate.
503 * {@inheritDoc}. 692 * {@inheritDoc}.
504 */ 693 */
505 devtools.DomAgent.prototype.setDocumentElement = function(payload) { 694 devtools.DomAgent.prototype.setDocumentElement = function(payload) {
506 if (this.document_.documentElement) { 695 var doc = this.getDocument();
696 if (doc.documentElement) {
507 return; 697 return;
508 } 698 }
509 this.setChildNodes(0, [payload]); 699 this.setChildNodes(0, [payload]);
510 this.document_.documentElement = this.document_.firstChild; 700 doc.documentElement = doc.firstChild;
511 this.document_.documentElement.ownerDocument = this.document_; 701 doc.documentElement.ownerDocument = doc;
512 this.document_.fireDomEvent_("DOMContentLoaded"); 702 doc.fireDomEvent_("DOMContentLoaded");
513 }; 703 };
514 704
515 705
516 /** 706 /**
517 * @see DomAgentDelegate. 707 * @see DomAgentDelegate.
518 * {@inheritDoc}. 708 * {@inheritDoc}.
519 */ 709 */
520 devtools.DomAgent.prototype.setChildNodes = function(parentId, payloads) { 710 devtools.DomAgent.prototype.setChildNodes = function(parentId, payloads) {
521 var parent = this.idToDomNode_[parentId]; 711 var parent = this.idToDomNode_[parentId];
522 if (parent.children) { 712 if (parent.children) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 * @see DomAgentDelegate. 744 * @see DomAgentDelegate.
555 * {@inheritDoc}. 745 * {@inheritDoc}.
556 */ 746 */
557 devtools.DomAgent.prototype.childNodeInserted = function( 747 devtools.DomAgent.prototype.childNodeInserted = function(
558 parentId, prevId, payload) { 748 parentId, prevId, payload) {
559 var parent = this.idToDomNode_[parentId]; 749 var parent = this.idToDomNode_[parentId];
560 var prev = this.idToDomNode_[prevId]; 750 var prev = this.idToDomNode_[prevId];
561 var node = parent.insertChild_(prev, payload); 751 var node = parent.insertChild_(prev, payload);
562 this.idToDomNode_[node.id_] = node; 752 this.idToDomNode_[node.id_] = node;
563 var event = { target : node, relatedNode : parent }; 753 var event = { target : node, relatedNode : parent };
564 this.document_.fireDomEvent_("DOMNodeInserted", event); 754 this.getDocument().fireDomEvent_("DOMNodeInserted", event);
565 }; 755 };
566 756
567 757
568 /** 758 /**
569 * @see DomAgentDelegate. 759 * @see DomAgentDelegate.
570 * {@inheritDoc}. 760 * {@inheritDoc}.
571 */ 761 */
572 devtools.DomAgent.prototype.childNodeRemoved = function( 762 devtools.DomAgent.prototype.childNodeRemoved = function(
573 parentId, nodeId) { 763 parentId, nodeId) {
574 var parent = this.idToDomNode_[parentId]; 764 var parent = this.idToDomNode_[parentId];
575 var node = this.idToDomNode_[nodeId]; 765 var node = this.idToDomNode_[nodeId];
576 parent.removeChild_(node); 766 parent.removeChild_(node);
577 var event = { target : node, relatedNode : parent }; 767 var event = { target : node, relatedNode : parent };
578 this.document_.fireDomEvent_("DOMNodeRemoved", event); 768 this.getDocument().fireDomEvent_("DOMNodeRemoved", event);
579 delete this.idToDomNode_[nodeId]; 769 delete this.idToDomNode_[nodeId];
580 }; 770 };
581 771
582 772
583 /** 773 /**
584 * @see DomAgentDelegate. 774 * @see DomAgentDelegate.
585 * {@inheritDoc}. 775 * {@inheritDoc}.
586 */ 776 */
587 devtools.DomAgent.prototype.performSearch = function(query, forEach) { 777 devtools.DomAgent.prototype.performSearch = function(query, forEach) {
588 RemoteDomAgent.PerformSearch( 778 RemoteDomAgent.PerformSearch(
(...skipping 25 matching lines...) Expand all
614 nodeIds) { 804 nodeIds) {
615 this.searchResults_ = []; 805 this.searchResults_ = [];
616 for (var i = 0; i < nodeIds.length; ++i) { 806 for (var i = 0; i < nodeIds.length; ++i) {
617 var node = this.idToDomNode_[nodeIds[i]]; 807 var node = this.idToDomNode_[nodeIds[i]];
618 this.searchResults_.push(nodeIds[i]); 808 this.searchResults_.push(nodeIds[i]);
619 forEach(node); 809 forEach(node);
620 } 810 }
621 }; 811 };
622 812
623 813
814 /**
815 * Asyncronously requests all the information about styles for the node.
816 * @param {devtools.DomNode} node to get styles for.
817 * @param {boolean} authorOnly is a parameter for getMatchedCSSRules
818 * @param {function()} callback invoked while the node filled up with styles
819 */
820 devtools.DomAgent.prototype.getNodeStylesAsync = function(node,
821 authorOnly,
822 callback) {
823 RemoteDomAgent.GetNodeStyles(
824 devtools.Callback.wrap(
825 goog.bind(this.getNodeStylesCallback_, this, node, callback)),
826 node.id_, authorOnly);
827 };
828
829
830 /**
831 * Accepts results of RemoteDomAgent.GetNodeStyles
832 * @param {devtools.DomNode} node of the reveived styles.
833 * @param {function()} callback to notify the getNodeStylesAsync caller.
834 * @param {object} styles is structure representing all the styles.
835 */
836 devtools.DomAgent.prototype.getNodeStylesCallback_ = function(node,
837 callback, styles) {
838
839 node.setStyles_(styles.computedStyle, styles.inlineStyle,
840 styles.styleAttributes, styles.matchedCSSRules);
841
842 callback();
843
844 node.clearStyles_();
845 };
846
847
624 function firstChildSkippingWhitespace() { 848 function firstChildSkippingWhitespace() {
625 return this.firstChild; 849 return this.firstChild;
626 } 850 }
627 851
628 852
629 function onlyTextChild() { 853 function onlyTextChild() {
630 if (!this.children) { 854 if (!this.children) {
631 return null; 855 return null;
632 } else if (this.children.length == 1 && 856 } else if (this.children.length == 1 &&
633 this.children[0].nodeType == Node.TEXT_NODE) { 857 this.children[0].nodeType == Node.TEXT_NODE) {
634 return this.children[0]; 858 return this.children[0];
635 } else { 859 } else {
636 return null; 860 return null;
637 } 861 }
638 } 862 }
OLDNEW
« no previous file with comments | « webkit/glue/devtools/js/devtools_host_stub.js ('k') | webkit/glue/devtools/js/inspector_controller_impl.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698