Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 320 if (!WebInspector.isWin() || (!this._openBracketIdentifiers[event.keyIde ntifier] && !this._closeBracketIdentifiers[event.keyIdentifier])) { | 320 if (!WebInspector.isWin() || (!this._openBracketIdentifiers[event.keyIde ntifier] && !this._closeBracketIdentifiers[event.keyIdentifier])) { |
| 321 this._keyDownInternal(event); | 321 this._keyDownInternal(event); |
| 322 return; | 322 return; |
| 323 } | 323 } |
| 324 | 324 |
| 325 this._keyDownTimer = setTimeout(this._keyDownInternal.bind(this, event), 0); | 325 this._keyDownTimer = setTimeout(this._keyDownInternal.bind(this, event), 0); |
| 326 }, | 326 }, |
| 327 | 327 |
| 328 _keyDownInternal: function(event) | 328 _keyDownInternal: function(event) |
| 329 { | 329 { |
| 330 if (this._openBracketIdentifiers[event.keyIdentifier]) { | 330 var direction = 0; |
| 331 var isRotateLeft = !event.shiftKey && !event.altKey; | |
| 332 if (isRotateLeft) { | |
| 333 var panelOrder = this._tabbedPane.allTabs(); | |
| 334 var index = panelOrder.indexOf(this.currentPanel().name); | |
| 335 index = (index === 0) ? panelOrder.length - 1 : index - 1; | |
| 336 this.showPanel(panelOrder[index]); | |
| 337 event.consume(true); | |
| 338 return; | |
| 339 } | |
| 340 | 331 |
| 341 var isGoBack = event.altKey; | 332 if (this._openBracketIdentifiers[event.keyIdentifier]) |
| 342 if (isGoBack && this._canGoBackInHistory()) { | 333 direction = -1; |
| 343 this._goBackInHistory(); | |
| 344 event.consume(true); | |
| 345 } | |
| 346 return; | |
| 347 } | |
| 348 | 334 |
| 349 if (this._closeBracketIdentifiers[event.keyIdentifier]) { | 335 if (this._closeBracketIdentifiers[event.keyIdentifier]) |
| 350 var isRotateRight = !event.shiftKey && !event.altKey; | 336 direction = 1; |
| 351 if (isRotateRight) { | |
| 352 var panelOrder = this._tabbedPane.allTabs(); | |
| 353 var index = panelOrder.indexOf(this.currentPanel().name); | |
| 354 index = (index + 1) % panelOrder.length; | |
| 355 this.showPanel(panelOrder[index]); | |
| 356 event.consume(true); | |
| 357 return; | |
| 358 } | |
| 359 | 337 |
| 360 var isGoForward = event.altKey; | 338 if (direction) { |
| 361 if (isGoForward && this._canGoForwardInHistory()) { | 339 this._handlePanelChangeShortcut(event, direction); |
| 362 this._goForwardInHistory(); | 340 this._handleHistoryMoveShortcut(event, direction); |
| 363 event.consume(true); | |
| 364 } | |
| 365 return; | |
| 366 } | 341 } |
| 367 }, | 342 }, |
| 368 | 343 |
| 369 _canGoBackInHistory: function() | 344 _handleHistoryMoveShortcut: function(event, move) |
|
vsevik
2014/03/04 17:29:56
I would inline event handling and extract history/
sergeyv
2014/03/04 17:55:42
Done.
| |
| 370 { | 345 { |
| 371 return this._historyIterator > 0; | 346 if (event.handled || !event.altKey || !this._isValidMoveInHistory(move)) |
| 347 return; | |
| 348 | |
| 349 this._moveInHistory(move); | |
| 350 event.consume(true); | |
| 372 }, | 351 }, |
| 373 | 352 |
| 374 _goBackInHistory: function() | 353 _handlePanelChangeShortcut: function(event, direction) |
|
vsevik
2014/03/04 17:29:56
Ditto.
sergeyv
2014/03/04 17:55:42
Done.
| |
| 354 { | |
| 355 if (event.handled || event.shiftKey || event.altKey) | |
| 356 return; | |
| 357 | |
| 358 var panelOrder = this._tabbedPane.allTabs(); | |
| 359 var index = panelOrder.indexOf(this.currentPanel().name); | |
| 360 index = (index + panelOrder.length + direction) % panelOrder.length; | |
| 361 this.showPanel(panelOrder[index]); | |
| 362 event.consume(true); | |
| 363 }, | |
| 364 | |
| 365 _isValidMoveInHistory: function(move) | |
|
vsevik
2014/03/04 17:29:56
This could be inlined into moveInHistory
sergeyv
2014/03/04 17:55:42
Done.
| |
| 366 { | |
| 367 var newIndex = this._historyIterator + move; | |
| 368 return newIndex < this._history.length && newIndex >= 0; | |
| 369 }, | |
| 370 | |
| 371 _moveInHistory: function(move) | |
| 375 { | 372 { |
| 376 this._inHistory = true; | 373 this._inHistory = true; |
| 377 this.setCurrentPanel(WebInspector.panels[this._history[--this._historyIt erator]]); | 374 this._historyIterator = this._historyIterator + move; |
| 375 this.setCurrentPanel(WebInspector.panels[this._history[this._historyIter ator]]); | |
| 378 delete this._inHistory; | 376 delete this._inHistory; |
| 379 }, | |
| 380 | 377 |
| 381 _canGoForwardInHistory: function() | |
| 382 { | |
| 383 return this._historyIterator < this._history.length - 1; | |
| 384 }, | |
| 385 | |
| 386 _goForwardInHistory: function() | |
| 387 { | |
| 388 this._inHistory = true; | |
| 389 this.setCurrentPanel(WebInspector.panels[this._history[++this._historyIt erator]]); | |
| 390 delete this._inHistory; | |
| 391 }, | 378 }, |
| 392 | 379 |
| 393 _pushToHistory: function(panelName) | 380 _pushToHistory: function(panelName) |
| 394 { | 381 { |
| 395 if (this._inHistory) | 382 if (this._inHistory) |
| 396 return; | 383 return; |
| 397 | 384 |
| 398 this._history.splice(this._historyIterator + 1, this._history.length - t his._historyIterator - 1); | 385 this._history.splice(this._historyIterator + 1, this._history.length - t his._historyIterator - 1); |
| 399 if (!this._history.length || this._history[this._history.length - 1] !== panelName) | 386 if (!this._history.length || this._history[this._history.length - 1] !== panelName) |
| 400 this._history.push(panelName); | 387 this._history.push(panelName); |
| 401 this._historyIterator = this._history.length - 1; | 388 this._historyIterator = this._history.length - 1; |
| 402 }, | 389 }, |
| 403 | 390 |
| 404 onResize: function() | 391 onResize: function() |
| 405 { | 392 { |
| 406 WebInspector.Dialog.modalHostRepositioned(); | 393 WebInspector.Dialog.modalHostRepositioned(); |
| 407 }, | 394 }, |
| 408 | 395 |
| 409 /** | 396 /** |
| 410 * @return {!Element} | 397 * @return {!Element} |
| 411 */ | 398 */ |
| 412 topResizerElement: function() | 399 topResizerElement: function() |
| 413 { | 400 { |
| 414 return this._tabbedPane.headerElement(); | 401 return this._tabbedPane.headerElement(); |
| 415 }, | 402 }, |
| 416 | 403 |
| 404 _createImagedCounterElementIfNeeded: function(count, id, styleName) | |
| 405 { | |
| 406 if (count) { | |
|
vsevik
2014/03/04 17:29:56
if (!count)
return
sergeyv
2014/03/04 17:55:42
Done.
| |
| 407 var imageElement = this._errorWarningCountElement.createChild("div", styleName); | |
| 408 var counterElement = this._errorWarningCountElement.createChild("spa n"); | |
| 409 counterElement.id = id; | |
| 410 counterElement.textContent = count; | |
| 411 } | |
| 412 }, | |
| 413 | |
| 417 /** | 414 /** |
| 418 * @param {number} errors | 415 * @param {number} errors |
| 419 * @param {number} warnings | 416 * @param {number} warnings |
| 420 */ | 417 */ |
| 421 setErrorAndWarningCounts: function(errors, warnings) | 418 setErrorAndWarningCounts: function(errors, warnings) |
| 422 { | 419 { |
| 423 if (!errors && !warnings) { | 420 this._errorWarningCountElement.enableStyleClass("hidden", !errors && !wa rnings); |
|
vsevik
2014/03/04 17:29:56
classList.toggle
sergeyv
2014/03/04 17:55:42
Done.
| |
| 424 this._errorWarningCountElement.classList.add("hidden"); | |
| 425 this._tabbedPane.headerResized(); | |
| 426 return; | |
| 427 } | |
| 428 | |
| 429 this._errorWarningCountElement.classList.remove("hidden"); | |
| 430 this._errorWarningCountElement.removeChildren(); | 421 this._errorWarningCountElement.removeChildren(); |
| 431 | 422 |
| 432 if (errors) { | 423 this._createImagedCounterElementIfNeeded(errors, "error-count", "error-i con-small"); |
| 433 var errorImageElement = this._errorWarningCountElement.createChild(" div", "error-icon-small"); | 424 this._createImagedCounterElementIfNeeded(warnings, "warning-count", "war ning-icon-small"); |
| 434 var errorElement = this._errorWarningCountElement.createChild("span" ); | |
| 435 errorElement.id = "error-count"; | |
| 436 errorElement.textContent = errors; | |
| 437 } | |
| 438 | 425 |
| 439 if (warnings) { | 426 var errorString = errors ? WebInspector.UIString("%d error%s", errors, errors > 1 ? "s" : "") : ""; |
| 440 var warningsImageElement = this._errorWarningCountElement.createChil d("div", "warning-icon-small"); | 427 var warningString = warnings ? WebInspector.UIString("%d warning%s", wa rnings, warnings > 1 ? "s" : "") : ""; |
| 441 var warningsElement = this._errorWarningCountElement.createChild("sp an"); | 428 var commaString = errors & warnings ? ", " : ""; |
|
vsevik
2014/03/04 17:29:56
did you mean &&?
sergeyv
2014/03/04 17:55:42
Done.
| |
| 442 warningsElement.id = "warning-count"; | 429 this._errorWarningCountElement.title = errorString + commaString + warni ngString; |
| 443 warningsElement.textContent = warnings; | |
| 444 } | |
| 445 | |
| 446 if (errors) { | |
| 447 if (warnings) { | |
| 448 if (errors == 1) { | |
| 449 if (warnings == 1) | |
| 450 this._errorWarningCountElement.title = WebInspector.UISt ring("%d error, %d warning", errors, warnings); | |
| 451 else | |
| 452 this._errorWarningCountElement.title = WebInspector.UISt ring("%d error, %d warnings", errors, warnings); | |
| 453 } else if (warnings == 1) | |
| 454 this._errorWarningCountElement.title = WebInspector.UIString ("%d errors, %d warning", errors, warnings); | |
| 455 else | |
| 456 this._errorWarningCountElement.title = WebInspector.UIString ("%d errors, %d warnings", errors, warnings); | |
| 457 } else if (errors == 1) | |
| 458 this._errorWarningCountElement.title = WebInspector.UIString("%d error", errors); | |
| 459 else | |
| 460 this._errorWarningCountElement.title = WebInspector.UIString("%d errors", errors); | |
| 461 } else if (warnings == 1) | |
| 462 this._errorWarningCountElement.title = WebInspector.UIString("%d war ning", warnings); | |
| 463 else if (warnings) | |
| 464 this._errorWarningCountElement.title = WebInspector.UIString("%d war nings", warnings); | |
| 465 else | |
| 466 this._errorWarningCountElement.title = null; | |
| 467 | |
| 468 this._tabbedPane.headerResized(); | 430 this._tabbedPane.headerResized(); |
| 469 }, | 431 }, |
| 470 | 432 |
| 471 __proto__: WebInspector.View.prototype | 433 __proto__: WebInspector.View.prototype |
| 472 }; | 434 }; |
| 473 | 435 |
| 474 /** | 436 /** |
| 475 * @type {!WebInspector.InspectorView} | 437 * @type {!WebInspector.InspectorView} |
| 476 */ | 438 */ |
| 477 WebInspector.inspectorView; | 439 WebInspector.inspectorView; |
| 478 | 440 |
| 479 /** | 441 /** |
| 480 * @constructor | 442 * @constructor |
| 481 * @extends {WebInspector.View} | 443 * @extends {WebInspector.View} |
| 482 */ | 444 */ |
| 483 WebInspector.RootView = function() | 445 WebInspector.RootView = function() |
| 484 { | 446 { |
| 485 WebInspector.View.call(this); | 447 WebInspector.View.call(this); |
| 486 this.markAsRoot(); | 448 this.markAsRoot(); |
| 487 this.element.classList.add("fill", "root-view"); | 449 this.element.classList.add("fill", "root-view"); |
| 488 this.element.setAttribute("spellcheck", false); | 450 this.element.setAttribute("spellcheck", false); |
| 489 window.addEventListener("resize", this.doResize.bind(this), true); | 451 window.addEventListener("resize", this.doResize.bind(this), true); |
| 490 }; | 452 }; |
| 491 | 453 |
| 492 WebInspector.RootView.prototype = { | 454 WebInspector.RootView.prototype = { |
| 493 __proto__: WebInspector.View.prototype | 455 __proto__: WebInspector.View.prototype |
| 494 }; | 456 }; |
| OLD | NEW |