| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 * @constructor | 6 * @constructor |
| 7 * @extends {WebInspector.HBox} | 7 * @extends {WebInspector.HBox} |
| 8 */ | 8 */ |
| 9 WebInspector.ElementsBreadcrumbs = function() | 9 WebInspector.ElementsBreadcrumbs = function() |
| 10 { | 10 { |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 var crumbs = this.crumbsElement; | 199 var crumbs = this.crumbsElement; |
| 200 if (!crumbs.firstChild) | 200 if (!crumbs.firstChild) |
| 201 return; | 201 return; |
| 202 | 202 |
| 203 var selectedIndex = 0; | 203 var selectedIndex = 0; |
| 204 var focusedIndex = 0; | 204 var focusedIndex = 0; |
| 205 var selectedCrumb; | 205 var selectedCrumb; |
| 206 | 206 |
| 207 // Reset crumb styles. | 207 // Reset crumb styles. |
| 208 for (var i = 0; i < crumbs.childNodes.length; ++i) { | 208 for (var i = 0; i < crumbs.childNodes.length; ++i) { |
| 209 var crumb = crumbs.childNodes[i]; | 209 var crumb = crumbs.children[i]; |
| 210 // Find the selected crumb and index. | 210 // Find the selected crumb and index. |
| 211 if (!selectedCrumb && crumb.classList.contains("selected")) { | 211 if (!selectedCrumb && crumb.classList.contains("selected")) { |
| 212 selectedCrumb = crumb; | 212 selectedCrumb = crumb; |
| 213 selectedIndex = i; | 213 selectedIndex = i; |
| 214 } | 214 } |
| 215 | 215 |
| 216 // Find the focused crumb index. | 216 // Find the focused crumb index. |
| 217 if (crumb === focusedCrumb) | 217 if (crumb === focusedCrumb) |
| 218 focusedIndex = i; | 218 focusedIndex = i; |
| 219 | 219 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 * @param {function(!Element)} shrinkingFunction | 277 * @param {function(!Element)} shrinkingFunction |
| 278 * @param {number} direction | 278 * @param {number} direction |
| 279 */ | 279 */ |
| 280 function makeCrumbsSmaller(shrinkingFunction, direction) | 280 function makeCrumbsSmaller(shrinkingFunction, direction) |
| 281 { | 281 { |
| 282 var significantCrumb = focusedCrumb || selectedCrumb; | 282 var significantCrumb = focusedCrumb || selectedCrumb; |
| 283 var significantIndex = significantCrumb === selectedCrumb ? selected
Index : focusedIndex; | 283 var significantIndex = significantCrumb === selectedCrumb ? selected
Index : focusedIndex; |
| 284 | 284 |
| 285 function shrinkCrumbAtIndex(index) | 285 function shrinkCrumbAtIndex(index) |
| 286 { | 286 { |
| 287 var shrinkCrumb = crumbs.childNodes[index]; | 287 var shrinkCrumb = crumbs.children[index]; |
| 288 if (shrinkCrumb && shrinkCrumb !== significantCrumb) | 288 if (shrinkCrumb && shrinkCrumb !== significantCrumb) |
| 289 shrinkingFunction(shrinkCrumb); | 289 shrinkingFunction(shrinkCrumb); |
| 290 if (crumbsAreSmallerThanContainer()) | 290 if (crumbsAreSmallerThanContainer()) |
| 291 return true; // No need to compact the crumbs more. | 291 return true; // No need to compact the crumbs more. |
| 292 return false; | 292 return false; |
| 293 } | 293 } |
| 294 | 294 |
| 295 // Shrink crumbs one at a time by applying the shrinkingFunction unt
il the crumbs | 295 // Shrink crumbs one at a time by applying the shrinkingFunction unt
il the crumbs |
| 296 // fit in the container or we run out of crumbs to shrink. | 296 // fit in the container or we run out of crumbs to shrink. |
| 297 if (direction) { | 297 if (direction) { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 compact(selectedCrumb); | 427 compact(selectedCrumb); |
| 428 if (crumbsAreSmallerThanContainer()) | 428 if (crumbsAreSmallerThanContainer()) |
| 429 return; | 429 return; |
| 430 | 430 |
| 431 // Collapse the selected crumb as a last resort. Pass true to prevent co
alescing. | 431 // Collapse the selected crumb as a last resort. Pass true to prevent co
alescing. |
| 432 collapse(selectedCrumb, true); | 432 collapse(selectedCrumb, true); |
| 433 }, | 433 }, |
| 434 | 434 |
| 435 __proto__: WebInspector.HBox.prototype | 435 __proto__: WebInspector.HBox.prototype |
| 436 } | 436 } |
| OLD | NEW |