| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). | 4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). |
| 5 * Copyright (C) 2009 Joseph Pecoraro | 5 * Copyright (C) 2009 Joseph Pecoraro |
| 6 * | 6 * |
| 7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
| 8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
| 9 * are met: | 9 * are met: |
| 10 * | 10 * |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 direction = "Up"; | 380 direction = "Up"; |
| 381 else if (event.key === "ArrowDown" || event.key === "PageDown") | 381 else if (event.key === "ArrowDown" || event.key === "PageDown") |
| 382 direction = "Down"; | 382 direction = "Down"; |
| 383 } | 383 } |
| 384 return direction; | 384 return direction; |
| 385 } | 385 } |
| 386 | 386 |
| 387 /** | 387 /** |
| 388 * @param {string} hexString | 388 * @param {string} hexString |
| 389 * @param {!Event} event | 389 * @param {!Event} event |
| 390 * @return {?string} |
| 390 */ | 391 */ |
| 391 WebInspector._modifiedHexValue = function(hexString, event) | 392 WebInspector._modifiedHexValue = function(hexString, event) |
| 392 { | 393 { |
| 393 var direction = WebInspector._valueModificationDirection(event); | 394 var direction = WebInspector._valueModificationDirection(event); |
| 394 if (!direction) | 395 if (!direction) |
| 395 return hexString; | 396 return null; |
| 396 | 397 |
| 397 var mouseEvent = /** @type {!MouseEvent} */(event); | 398 var mouseEvent = /** @type {!MouseEvent} */(event); |
| 398 var number = parseInt(hexString, 16); | 399 var number = parseInt(hexString, 16); |
| 399 if (isNaN(number) || !isFinite(number)) | 400 if (isNaN(number) || !isFinite(number)) |
| 400 return hexString; | 401 return null; |
| 401 | 402 |
| 402 var hexStrLen = hexString.length; | 403 var hexStrLen = hexString.length; |
| 403 var channelLen = hexStrLen / 3; | 404 var channelLen = hexStrLen / 3; |
| 404 | 405 |
| 405 // Colors are either rgb or rrggbb. | 406 // Colors are either rgb or rrggbb. |
| 406 if (channelLen !== 1 && channelLen !== 2) | 407 if (channelLen !== 1 && channelLen !== 2) |
| 407 return hexString; | 408 return null; |
| 408 | 409 |
| 409 // Precision modifier keys work with both mousewheel and up/down keys. | 410 // Precision modifier keys work with both mousewheel and up/down keys. |
| 410 // When ctrl is pressed, increase R by 1. | 411 // When ctrl is pressed, increase R by 1. |
| 411 // When shift is pressed, increase G by 1. | 412 // When shift is pressed, increase G by 1. |
| 412 // When alt is pressed, increase B by 1. | 413 // When alt is pressed, increase B by 1. |
| 413 // If no shortcut keys are pressed then increase hex value by 1. | 414 // If no shortcut keys are pressed then increase hex value by 1. |
| 414 // Keys can be pressed together to increase RGB channels. e.g trying differe
nt shades. | 415 // Keys can be pressed together to increase RGB channels. e.g trying differe
nt shades. |
| 415 var delta = 0; | 416 var delta = 0; |
| 416 if (WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(mouseEvent)) | 417 if (WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(mouseEvent)) |
| 417 delta += Math.pow(16, channelLen * 2); | 418 delta += Math.pow(16, channelLen * 2); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 431 // Ensure the result length is the same as the original hex value. | 432 // Ensure the result length is the same as the original hex value. |
| 432 var resultString = result.toString(16).toUpperCase(); | 433 var resultString = result.toString(16).toUpperCase(); |
| 433 for (var i = 0, lengthDelta = hexStrLen - resultString.length; i < lengthDel
ta; ++i) | 434 for (var i = 0, lengthDelta = hexStrLen - resultString.length; i < lengthDel
ta; ++i) |
| 434 resultString = "0" + resultString; | 435 resultString = "0" + resultString; |
| 435 return resultString; | 436 return resultString; |
| 436 } | 437 } |
| 437 | 438 |
| 438 /** | 439 /** |
| 439 * @param {number} number | 440 * @param {number} number |
| 440 * @param {!Event} event | 441 * @param {!Event} event |
| 442 * @return {?number} |
| 441 */ | 443 */ |
| 442 WebInspector._modifiedFloatNumber = function(number, event) | 444 WebInspector._modifiedFloatNumber = function(number, event) |
| 443 { | 445 { |
| 444 var direction = WebInspector._valueModificationDirection(event); | 446 var direction = WebInspector._valueModificationDirection(event); |
| 445 if (!direction) | 447 if (!direction) |
| 446 return number; | 448 return null; |
| 447 | 449 |
| 448 var mouseEvent = /** @type {!MouseEvent} */(event); | 450 var mouseEvent = /** @type {!MouseEvent} */(event); |
| 449 | 451 |
| 450 // Precision modifier keys work with both mousewheel and up/down keys. | 452 // Precision modifier keys work with both mousewheel and up/down keys. |
| 451 // When ctrl is pressed, increase by 100. | 453 // When ctrl is pressed, increase by 100. |
| 452 // When shift is pressed, increase by 10. | 454 // When shift is pressed, increase by 10. |
| 453 // When alt is pressed, increase by 0.1. | 455 // When alt is pressed, increase by 0.1. |
| 454 // Otherwise increase by 1. | 456 // Otherwise increase by 1. |
| 455 var delta = 1; | 457 var delta = 1; |
| 456 if (WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(mouseEvent)) | 458 if (WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(mouseEvent)) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 473 } | 475 } |
| 474 | 476 |
| 475 /** | 477 /** |
| 476 * @param {string} wordString | 478 * @param {string} wordString |
| 477 * @param {!Event} event | 479 * @param {!Event} event |
| 478 * @param {function(string, number, string):string=} customNumberHandler | 480 * @param {function(string, number, string):string=} customNumberHandler |
| 479 * @return {?string} | 481 * @return {?string} |
| 480 */ | 482 */ |
| 481 WebInspector.createReplacementString = function(wordString, event, customNumberH
andler) | 483 WebInspector.createReplacementString = function(wordString, event, customNumberH
andler) |
| 482 { | 484 { |
| 483 var replacementString; | 485 var prefix; |
| 484 var prefix, suffix, number; | 486 var suffix; |
| 485 | 487 var number; |
| 486 var matches; | 488 var replacementString = null; |
| 487 matches = /(.*#)([\da-fA-F]+)(.*)/.exec(wordString); | 489 var matches = /(.*#)([\da-fA-F]+)(.*)/.exec(wordString); |
| 488 if (matches && matches.length) { | 490 if (matches && matches.length) { |
| 489 prefix = matches[1]; | 491 prefix = matches[1]; |
| 490 suffix = matches[3]; | 492 suffix = matches[3]; |
| 491 number = WebInspector._modifiedHexValue(matches[2], event); | 493 number = WebInspector._modifiedHexValue(matches[2], event); |
| 492 | 494 if (number !== null) |
| 493 replacementString = customNumberHandler ? customNumberHandler(prefix, nu
mber, suffix) : prefix + number + suffix; | 495 replacementString = prefix + number + suffix; |
| 494 } else { | 496 } else { |
| 495 matches = /(.*?)(-?(?:\d+(?:\.\d+)?|\.\d+))(.*)/.exec(wordString); | 497 matches = /(.*?)(-?(?:\d+(?:\.\d+)?|\.\d+))(.*)/.exec(wordString); |
| 496 if (matches && matches.length) { | 498 if (matches && matches.length) { |
| 497 prefix = matches[1]; | 499 prefix = matches[1]; |
| 498 suffix = matches[3]; | 500 suffix = matches[3]; |
| 499 number = WebInspector._modifiedFloatNumber(parseFloat(matches[2]), e
vent); | 501 number = WebInspector._modifiedFloatNumber(parseFloat(matches[2]), e
vent); |
| 500 | 502 if (number !== null) |
| 501 // Need to check for null explicitly. | 503 replacementString = customNumberHandler ? customNumberHandler(pr
efix, number, suffix) : prefix + number + suffix; |
| 502 if (number === null) | |
| 503 return null; | |
| 504 | |
| 505 replacementString = customNumberHandler ? customNumberHandler(prefix
, number, suffix) : prefix + number + suffix; | |
| 506 } | 504 } |
| 507 } | 505 } |
| 508 return replacementString || null; | 506 return replacementString; |
| 509 } | 507 } |
| 510 | 508 |
| 511 /** | 509 /** |
| 512 * @param {!Event} event | 510 * @param {!Event} event |
| 513 * @param {!Element} element | 511 * @param {!Element} element |
| 514 * @param {function(string,string)=} finishHandler | 512 * @param {function(string,string)=} finishHandler |
| 515 * @param {function(string)=} suggestionHandler | 513 * @param {function(string)=} suggestionHandler |
| 516 * @param {function(string, number, string):string=} customNumberHandler | 514 * @param {function(string, number, string):string=} customNumberHandler |
| 517 * @return {boolean} | 515 * @return {boolean} |
| 518 */ | 516 */ |
| (...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2006 * @param {string} title | 2004 * @param {string} title |
| 2007 * @return {!Element} | 2005 * @return {!Element} |
| 2008 */ | 2006 */ |
| 2009 WebInspector.linkifyDocumentationURLAsNode = function(article, title) | 2007 WebInspector.linkifyDocumentationURLAsNode = function(article, title) |
| 2010 { | 2008 { |
| 2011 return WebInspector.linkifyURLAsNode("https://developers.google.com/web/tool
s/chrome-devtools/" + article, title, undefined, true); | 2009 return WebInspector.linkifyURLAsNode("https://developers.google.com/web/tool
s/chrome-devtools/" + article, title, undefined, true); |
| 2012 } | 2010 } |
| 2013 | 2011 |
| 2014 /** @type {!WebInspector.ThemeSupport} */ | 2012 /** @type {!WebInspector.ThemeSupport} */ |
| 2015 WebInspector.themeSupport; | 2013 WebInspector.themeSupport; |
| OLD | NEW |