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

Side by Side Diff: chrome/tools/test/reference_build/chrome_linux/resources/inspector/treeoutline.js

Issue 177049: On Linux, move the passing of filedescriptors to a dedicated socketpair(). (Closed)
Patch Set: Removed *.d files from reference build Created 11 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 242
243 TreeOutline.prototype._forgetChildrenRecursive = function(parentElement) 243 TreeOutline.prototype._forgetChildrenRecursive = function(parentElement)
244 { 244 {
245 var child = parentElement.children[0]; 245 var child = parentElement.children[0];
246 while (child) { 246 while (child) {
247 this._forgetTreeElement(child); 247 this._forgetTreeElement(child);
248 child = child.traverseNextTreeElement(false, this, true); 248 child = child.traverseNextTreeElement(false, this, true);
249 } 249 }
250 } 250 }
251 251
252 TreeOutline.prototype.findTreeElement = function(representedObject, isAncestor, getParent, equal) 252 TreeOutline.prototype.getCachedTreeElement = function(representedObject)
253 { 253 {
254 if (!representedObject) 254 if (!representedObject)
255 return null; 255 return null;
256 256
257 if (!equal)
258 equal = function(a, b) { return a === b };
259
260 if ("__treeElementIdentifier" in representedObject) { 257 if ("__treeElementIdentifier" in representedObject) {
261 // If this representedObject has a tree element identifier, and it is a known TreeElement 258 // If this representedObject has a tree element identifier, and it is a known TreeElement
262 // in our tree we can just return that tree element. 259 // in our tree we can just return that tree element.
263 var elements = this._knownTreeElements[representedObject.__treeElementId entifier]; 260 var elements = this._knownTreeElements[representedObject.__treeElementId entifier];
264 if (elements) { 261 if (elements) {
265 for (var i = 0; i < elements.length; ++i) 262 for (var i = 0; i < elements.length; ++i)
266 if (equal(elements[i].representedObject, representedObject)) 263 if (elements[i].representedObject === representedObject)
267 return elements[i]; 264 return elements[i];
268 } 265 }
269 } 266 }
267 return null;
268 }
270 269
271 if (!isAncestor || !(isAncestor instanceof Function) || !getParent || !(getP arent instanceof Function)) 270 TreeOutline.prototype.findTreeElement = function(representedObject, isAncestor, getParent)
271 {
272 if (!representedObject)
272 return null; 273 return null;
273 274
275 var cachedElement = this.getCachedTreeElement(representedObject);
276 if (cachedElement)
277 return cachedElement;
278
274 // The representedObject isn't know, so we start at the top of the tree and work down to find the first 279 // The representedObject isn't know, so we start at the top of the tree and work down to find the first
275 // tree element that represents representedObject or one of its ancestors. 280 // tree element that represents representedObject or one of its ancestors.
276 var item; 281 var item;
277 var found = false; 282 var found = false;
278 for (var i = 0; i < this.children.length; ++i) { 283 for (var i = 0; i < this.children.length; ++i) {
279 item = this.children[i]; 284 item = this.children[i];
280 if (equal(item.representedObject, representedObject) || isAncestor(item. representedObject, representedObject)) { 285 if (item.representedObject === representedObject || isAncestor(item.repr esentedObject, representedObject)) {
281 found = true; 286 found = true;
282 break; 287 break;
283 } 288 }
284 } 289 }
285 290
286 if (!found) 291 if (!found)
287 return null; 292 return null;
288 293
289 // Make sure the item that we found is connected to the root of the tree. 294 // Make sure the item that we found is connected to the root of the tree.
290 // Build up a list of representedObject's ancestors that aren't already in o ur tree. 295 // Build up a list of representedObject's ancestors that aren't already in o ur tree.
291 var ancestors = []; 296 var ancestors = [];
292 var currentObject = representedObject; 297 var currentObject = representedObject;
293 while (currentObject) { 298 while (currentObject) {
294 ancestors.unshift(currentObject); 299 ancestors.unshift(currentObject);
295 if (equal(currentObject, item.representedObject)) 300 if (currentObject === item.representedObject)
296 break; 301 break;
297 currentObject = getParent(currentObject); 302 currentObject = getParent(currentObject);
298 } 303 }
299 304
300 // For each of those ancestors we populate them to fill in the tree. 305 // For each of those ancestors we populate them to fill in the tree.
301 for (var i = 0; i < ancestors.length; ++i) { 306 for (var i = 0; i < ancestors.length; ++i) {
302 // Make sure we don't call findTreeElement with the same representedObje ct 307 // Make sure we don't call findTreeElement with the same representedObje ct
303 // again, to prevent infinite recursion. 308 // again, to prevent infinite recursion.
304 if (equal(ancestors[i], representedObject)) 309 if (ancestors[i] === representedObject)
305 continue; 310 continue;
306 // FIXME: we could do something faster than findTreeElement since we wil l know the next 311 // FIXME: we could do something faster than findTreeElement since we wil l know the next
307 // ancestor exists in the tree. 312 // ancestor exists in the tree.
308 item = this.findTreeElement(ancestors[i], isAncestor, getParent, equal); 313 item = this.findTreeElement(ancestors[i], isAncestor, getParent);
309 if (item && item.onpopulate) 314 if (item && item.onpopulate)
310 item.onpopulate(item); 315 item.onpopulate(item);
311 } 316 }
312 317
313 // Now that all the ancestors are populated, try to find the representedObje ct again. This time 318 return this.getCachedTreeElement(representedObject);
314 // without the isAncestor and getParent functions to prevent an infinite rec ursion if it isn't found.
315 return this.findTreeElement(representedObject, null, null, equal);
316 } 319 }
317 320
318 TreeOutline.prototype.treeElementFromPoint = function(x, y) 321 TreeOutline.prototype.treeElementFromPoint = function(x, y)
319 { 322 {
320 var node = this._childrenListNode.ownerDocument.elementFromPoint(x, y); 323 var node = this._childrenListNode.ownerDocument.elementFromPoint(x, y);
321 var listNode = node.enclosingNodeOrSelfWithNodeNameInArray(["ol", "li"]); 324 var listNode = node.enclosingNodeOrSelfWithNodeNameInArray(["ol", "li"]);
322 if (listNode) 325 if (listNode)
323 return listNode.parentTreeElement || listNode.treeElement; 326 return listNode.parentTreeElement || listNode.treeElement;
324 return null; 327 return null;
325 } 328 }
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 return null; 840 return null;
838 841
839 return this.parent; 842 return this.parent;
840 } 843 }
841 844
842 TreeElement.prototype.isEventWithinDisclosureTriangle = function(event) 845 TreeElement.prototype.isEventWithinDisclosureTriangle = function(event)
843 { 846 {
844 var left = this._listItemNode.totalOffsetLeft; 847 var left = this._listItemNode.totalOffsetLeft;
845 return event.pageX >= left && event.pageX <= left + this.arrowToggleWidth && this.hasChildren; 848 return event.pageX >= left && event.pageX <= left + this.arrowToggleWidth && this.hasChildren;
846 } 849 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698