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

Side by Side Diff: Source/devtools/front_end/elements/ElementsBreadcrumbs.js

Issue 1353473004: Revert of Devtools UI: Upgrade breadcrumbs to material design UI (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/devtools/front_end/elements/ElementsPanel.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
220 crumb.classList.remove("compact", "collapsed", "hidden"); 220 crumb.classList.remove("compact", "collapsed", "hidden");
221 } 221 }
222 222
223 // Layout 1: Measure total and normal crumb sizes 223 // Layout 1: Measure total and normal crumb sizes
224 var contentElementWidth = this.contentElement.offsetWidth; 224 var contentElementWidth = this.contentElement.offsetWidth;
225 var margin = parseInt(window.getComputedStyle(/** @type {!Element} */(cr umbs.firstChild)).marginLeft, 10) * 2;
226 var normalSizes = []; 225 var normalSizes = [];
227 for (var i = 0; i < crumbs.childNodes.length; ++i) { 226 for (var i = 0; i < crumbs.childNodes.length; ++i) {
228 var crumb = crumbs.childNodes[i]; 227 var crumb = crumbs.childNodes[i];
229 normalSizes[i] = crumb.offsetWidth + margin; 228 normalSizes[i] = crumb.offsetWidth;
230 } 229 }
231 230
232 // Layout 2: Measure collapsed crumb sizes 231 // Layout 2: Measure collapsed crumb sizes
233 var compactSizes = []; 232 var compactSizes = [];
234 for (var i = 0; i < crumbs.childNodes.length; ++i) { 233 for (var i = 0; i < crumbs.childNodes.length; ++i) {
235 var crumb = crumbs.childNodes[i]; 234 var crumb = crumbs.childNodes[i];
236 crumb.classList.add("compact"); 235 crumb.classList.add("compact");
237 } 236 }
238 for (var i = 0; i < crumbs.childNodes.length; ++i) { 237 for (var i = 0; i < crumbs.childNodes.length; ++i) {
239 var crumb = crumbs.childNodes[i]; 238 var crumb = crumbs.childNodes[i];
240 compactSizes[i] = crumb.offsetWidth + margin; 239 compactSizes[i] = crumb.offsetWidth;
241 } 240 }
242 241
243 // Layout 3: Measure collapsed crumb size 242 // Layout 3: Measure collapsed crumb size
244 crumbs.firstChild.classList.add("collapsed"); 243 crumbs.firstChild.classList.add("collapsed");
245 var collapsedSize = crumbs.firstChild.offsetWidth + margin; 244 var collapsedSize = crumbs.firstChild.offsetWidth;
246 245
247 // Clean up. 246 // Clean up.
248 for (var i = 0; i < crumbs.childNodes.length; ++i) { 247 for (var i = 0; i < crumbs.childNodes.length; ++i) {
249 var crumb = crumbs.childNodes[i]; 248 var crumb = crumbs.childNodes[i];
250 crumb.classList.remove("compact", "collapsed"); 249 crumb.classList.remove("compact", "collapsed");
251 } 250 }
252 251
253 function crumbsAreSmallerThanContainer() 252 function crumbsAreSmallerThanContainer()
254 { 253 {
255 var totalSize = 0; 254 var totalSize = 0;
256 for (var i = 0; i < crumbs.childNodes.length; ++i) { 255 for (var i = 0; i < crumbs.childNodes.length; ++i) {
257 var crumb = crumbs.childNodes[i]; 256 var crumb = crumbs.childNodes[i];
258 if (crumb.classList.contains("hidden")) 257 if (crumb.classList.contains("hidden"))
259 continue; 258 continue;
260 if (crumb.classList.contains("collapsed")) { 259 if (crumb.classList.contains("collapsed")) {
261 totalSize += collapsedSize; 260 totalSize += collapsedSize;
262 continue; 261 continue;
263 } 262 }
264 totalSize += crumb.classList.contains("compact") ? compactSizes[ i] : normalSizes[i]; 263 totalSize += crumb.classList.contains("compact") ? compactSizes[ i] : normalSizes[i];
265 } 264 }
266 const rightPadding = 4; 265 const rightPadding = 10;
267 return totalSize + rightPadding < contentElementWidth; 266 return totalSize + rightPadding < contentElementWidth;
268 } 267 }
269 268
270 if (crumbsAreSmallerThanContainer()) 269 if (crumbsAreSmallerThanContainer())
271 return; // No need to compact the crumbs, they all fit at full size. 270 return; // No need to compact the crumbs, they all fit at full size.
272 271
273 var BothSides = 0; 272 var BothSides = 0;
274 var AncestorSide = -1; 273 var AncestorSide = -1;
275 var ChildSide = 1; 274 var ChildSide = 1;
276 275
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 compact(selectedCrumb); 427 compact(selectedCrumb);
429 if (crumbsAreSmallerThanContainer()) 428 if (crumbsAreSmallerThanContainer())
430 return; 429 return;
431 430
432 // 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.
433 collapse(selectedCrumb, true); 432 collapse(selectedCrumb, true);
434 }, 433 },
435 434
436 __proto__: WebInspector.HBox.prototype 435 __proto__: WebInspector.HBox.prototype
437 } 436 }
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/elements/ElementsPanel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698