Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * Copyright (C) 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 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 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1266 WebInspector.RevisionHistoryView.showHistory(uiSourceCode); | 1266 WebInspector.RevisionHistoryView.showHistory(uiSourceCode); |
| 1267 }, | 1267 }, |
| 1268 | 1268 |
| 1269 /** | 1269 /** |
| 1270 * @param {!WebInspector.ContextMenu} contextMenu | 1270 * @param {!WebInspector.ContextMenu} contextMenu |
| 1271 * @param {!Object} target | 1271 * @param {!Object} target |
| 1272 */ | 1272 */ |
| 1273 appendApplicableItems: function(event, contextMenu, target) | 1273 appendApplicableItems: function(event, contextMenu, target) |
| 1274 { | 1274 { |
| 1275 this._appendUISourceCodeItems(event, contextMenu, target); | 1275 this._appendUISourceCodeItems(event, contextMenu, target); |
| 1276 this._appendFunctionItems(contextMenu, target); | 1276 this._appendRemoteObjectItems(contextMenu, target); |
| 1277 }, | 1277 }, |
| 1278 | 1278 |
| 1279 _suggestReload: function() | 1279 _suggestReload: function() |
| 1280 { | 1280 { |
| 1281 if (window.confirm(WebInspector.UIString("It is recommended to restart i nspector after making these changes. Would you like to restart it?"))) | 1281 if (window.confirm(WebInspector.UIString("It is recommended to restart i nspector after making these changes. Would you like to restart it?"))) |
| 1282 WebInspector.reload(); | 1282 WebInspector.reload(); |
| 1283 }, | 1283 }, |
| 1284 | 1284 |
| 1285 /** | 1285 /** |
| 1286 * @param {!WebInspector.UISourceCode} uiSourceCode | 1286 * @param {!WebInspector.UISourceCode} uiSourceCode |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1384 _handleContextMenuReveal: function(uiSourceCode) | 1384 _handleContextMenuReveal: function(uiSourceCode) |
| 1385 { | 1385 { |
| 1386 this.editorView.showBoth(); | 1386 this.editorView.showBoth(); |
| 1387 this._revealInNavigator(uiSourceCode); | 1387 this._revealInNavigator(uiSourceCode); |
| 1388 }, | 1388 }, |
| 1389 | 1389 |
| 1390 /** | 1390 /** |
| 1391 * @param {!WebInspector.ContextMenu} contextMenu | 1391 * @param {!WebInspector.ContextMenu} contextMenu |
| 1392 * @param {!Object} target | 1392 * @param {!Object} target |
| 1393 */ | 1393 */ |
| 1394 _appendFunctionItems: function(contextMenu, target) | 1394 _appendRemoteObjectItems: function(contextMenu, target) |
| 1395 { | 1395 { |
| 1396 if (!(target instanceof WebInspector.RemoteObject)) | 1396 if (!(target instanceof WebInspector.RemoteObject)) |
| 1397 return; | 1397 return; |
| 1398 var remoteObject = /** @type {!WebInspector.RemoteObject} */ (target); | 1398 var remoteObject = /** @type {!WebInspector.RemoteObject} */ (target); |
| 1399 if (remoteObject.type !== "function") | 1399 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Save to temp variable" : "Save to Temp Variable"), this._saveToTem pVariable.bind(this, remoteObject)); |
|
pfeldman
2014/03/19 18:08:03
"Store as global variable"
aandrey
2014/03/20 09:21:22
Done.
| |
| 1400 return; | 1400 if (remoteObject.type === "function") |
| 1401 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCa seMenuTitles() ? "Show function definition" : "Show Function Definition"), this. _showFunctionDefinition.bind(this, remoteObject)); | |
| 1402 }, | |
| 1401 | 1403 |
| 1404 /** | |
| 1405 * @param {!WebInspector.RemoteObject} remoteObject | |
| 1406 */ | |
| 1407 _saveToTempVariable: function(remoteObject) | |
| 1408 { | |
| 1409 WebInspector.runtimeModel.evaluate("window", "", false, true, false, fal se, didGetGlobalObject); | |
| 1410 | |
| 1411 /** | |
| 1412 * @param {?WebInspector.RemoteObject} global | |
| 1413 * @param {boolean=} wasThrown | |
| 1414 */ | |
| 1415 function didGetGlobalObject(global, wasThrown) | |
| 1416 { | |
| 1417 /** @this {Window} */ | |
| 1418 function remoteFunction(value) | |
| 1419 { | |
| 1420 var prefix = "temp"; | |
| 1421 var index = 1; | |
| 1422 while ((prefix + index) in this) | |
| 1423 ++index; | |
| 1424 var name = prefix + index; | |
| 1425 this[name] = value; | |
| 1426 return name; | |
| 1427 } | |
| 1428 | |
| 1429 if (wasThrown || !global) | |
| 1430 failedToSave(global); | |
| 1431 else | |
| 1432 global.callFunction(remoteFunction, [WebInspector.RemoteObject.t oCallArgument(remoteObject)], didSave.bind(null, global)); | |
| 1433 } | |
| 1434 | |
| 1435 /** | |
| 1436 * @param {!WebInspector.RemoteObject} global | |
| 1437 * @param {?WebInspector.RemoteObject} result | |
| 1438 * @param {boolean=} wasThrown | |
| 1439 */ | |
| 1440 function didSave(global, result, wasThrown) | |
| 1441 { | |
| 1442 global.release(); | |
| 1443 if (wasThrown || !result || result.type !== "string") | |
| 1444 failedToSave(result); | |
| 1445 else | |
| 1446 WebInspector.console.evaluate(result.value); | |
| 1447 } | |
| 1448 | |
| 1449 /** | |
| 1450 * @param {?WebInspector.RemoteObject} result | |
| 1451 */ | |
| 1452 function failedToSave(result) | |
| 1453 { | |
| 1454 var message = WebInspector.UIString("Failed to save to temp variable ."); | |
| 1455 if (result) { | |
| 1456 message += " " + result.description; | |
| 1457 result.release(); | |
| 1458 } | |
| 1459 WebInspector.console.showErrorMessage(message) | |
| 1460 } | |
| 1461 }, | |
| 1462 | |
| 1463 /** | |
| 1464 * @param {!WebInspector.RemoteObject} remoteObject | |
| 1465 */ | |
| 1466 _showFunctionDefinition: function(remoteObject) | |
| 1467 { | |
| 1402 /** | 1468 /** |
| 1403 * @param {?Protocol.Error} error | 1469 * @param {?Protocol.Error} error |
| 1404 * @param {!DebuggerAgent.FunctionDetails} response | 1470 * @param {!DebuggerAgent.FunctionDetails} response |
| 1405 * @this {WebInspector.SourcesPanel} | 1471 * @this {WebInspector.SourcesPanel} |
| 1406 */ | 1472 */ |
| 1407 function didGetDetails(error, response) | 1473 function didGetFunctionDetails(error, response) |
| 1408 { | 1474 { |
| 1409 if (error) { | 1475 if (error) { |
| 1410 console.error(error); | 1476 console.error(error); |
| 1411 return; | 1477 return; |
| 1412 } | 1478 } |
| 1413 | 1479 |
| 1414 var uiLocation = WebInspector.debuggerModel.rawLocationToUILocation( response.location); | 1480 var uiLocation = WebInspector.debuggerModel.rawLocationToUILocation( response.location); |
| 1415 if (!uiLocation) | 1481 if (!uiLocation) |
| 1416 return; | 1482 return; |
| 1417 | 1483 |
| 1418 this.showUILocation(uiLocation, true); | 1484 this.showUILocation(uiLocation, true); |
| 1419 } | 1485 } |
| 1420 | 1486 DebuggerAgent.getFunctionDetails(remoteObject.objectId, didGetFunctionDe tails.bind(this)); |
| 1421 /** | |
| 1422 * @this {WebInspector.SourcesPanel} | |
| 1423 */ | |
| 1424 function revealFunction() | |
| 1425 { | |
| 1426 DebuggerAgent.getFunctionDetails(remoteObject.objectId, didGetDetail s.bind(this)); | |
| 1427 } | |
| 1428 | |
| 1429 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Show function definition" : "Show Function Definition"), revealFun ction.bind(this)); | |
| 1430 }, | 1487 }, |
| 1431 | 1488 |
| 1432 /** | 1489 /** |
| 1433 * @param {string=} query | 1490 * @param {string=} query |
| 1434 */ | 1491 */ |
| 1435 _showOpenResourceDialog: function(query) | 1492 _showOpenResourceDialog: function(query) |
| 1436 { | 1493 { |
| 1437 var uiSourceCodes = this._editorContainer.historyUISourceCodes(); | 1494 var uiSourceCodes = this._editorContainer.historyUISourceCodes(); |
| 1438 /** @type {!Map.<!WebInspector.UISourceCode, number>} */ | 1495 /** @type {!Map.<!WebInspector.UISourceCode, number>} */ |
| 1439 var defaultScores = new Map(); | 1496 var defaultScores = new Map(); |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1722 { | 1779 { |
| 1723 } | 1780 } |
| 1724 | 1781 |
| 1725 WebInspector.SourcesPanel.EditorAction.prototype = { | 1782 WebInspector.SourcesPanel.EditorAction.prototype = { |
| 1726 /** | 1783 /** |
| 1727 * @param {!WebInspector.SourcesPanel} panel | 1784 * @param {!WebInspector.SourcesPanel} panel |
| 1728 * @return {!Element} | 1785 * @return {!Element} |
| 1729 */ | 1786 */ |
| 1730 button: function(panel) { } | 1787 button: function(panel) { } |
| 1731 } | 1788 } |
| OLD | NEW |