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 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1260 WebInspector.RevisionHistoryView.showHistory(uiSourceCode); | 1260 WebInspector.RevisionHistoryView.showHistory(uiSourceCode); |
1261 }, | 1261 }, |
1262 | 1262 |
1263 /** | 1263 /** |
1264 * @param {!WebInspector.ContextMenu} contextMenu | 1264 * @param {!WebInspector.ContextMenu} contextMenu |
1265 * @param {!Object} target | 1265 * @param {!Object} target |
1266 */ | 1266 */ |
1267 appendApplicableItems: function(event, contextMenu, target) | 1267 appendApplicableItems: function(event, contextMenu, target) |
1268 { | 1268 { |
1269 this._appendUISourceCodeItems(event, contextMenu, target); | 1269 this._appendUISourceCodeItems(event, contextMenu, target); |
1270 this._appendFunctionItems(contextMenu, target); | 1270 this._appendRemoteObjectItems(contextMenu, target); |
1271 }, | 1271 }, |
1272 | 1272 |
1273 _suggestReload: function() | 1273 _suggestReload: function() |
1274 { | 1274 { |
1275 if (window.confirm(WebInspector.UIString("It is recommended to restart i
nspector after making these changes. Would you like to restart it?"))) | 1275 if (window.confirm(WebInspector.UIString("It is recommended to restart i
nspector after making these changes. Would you like to restart it?"))) |
1276 WebInspector.reload(); | 1276 WebInspector.reload(); |
1277 }, | 1277 }, |
1278 | 1278 |
1279 /** | 1279 /** |
1280 * @param {!WebInspector.UISourceCode} uiSourceCode | 1280 * @param {!WebInspector.UISourceCode} uiSourceCode |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1378 _handleContextMenuReveal: function(uiSourceCode) | 1378 _handleContextMenuReveal: function(uiSourceCode) |
1379 { | 1379 { |
1380 this.editorView.showBoth(); | 1380 this.editorView.showBoth(); |
1381 this._revealInNavigator(uiSourceCode); | 1381 this._revealInNavigator(uiSourceCode); |
1382 }, | 1382 }, |
1383 | 1383 |
1384 /** | 1384 /** |
1385 * @param {!WebInspector.ContextMenu} contextMenu | 1385 * @param {!WebInspector.ContextMenu} contextMenu |
1386 * @param {!Object} target | 1386 * @param {!Object} target |
1387 */ | 1387 */ |
1388 _appendFunctionItems: function(contextMenu, target) | 1388 _appendRemoteObjectItems: function(contextMenu, target) |
1389 { | 1389 { |
1390 if (!(target instanceof WebInspector.RemoteObject)) | 1390 if (!(target instanceof WebInspector.RemoteObject)) |
1391 return; | 1391 return; |
1392 var remoteObject = /** @type {!WebInspector.RemoteObject} */ (target); | 1392 var remoteObject = /** @type {!WebInspector.RemoteObject} */ (target); |
1393 if (remoteObject.type !== "function") | 1393 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe
nuTitles() ? "Store as global variable" : "Store as Global Variable"), this._sav
eToTempVariable.bind(this, remoteObject)); |
1394 return; | 1394 if (remoteObject.type === "function") |
| 1395 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCa
seMenuTitles() ? "Show function definition" : "Show Function Definition"), this.
_showFunctionDefinition.bind(this, remoteObject)); |
| 1396 }, |
1395 | 1397 |
| 1398 /** |
| 1399 * @param {!WebInspector.RemoteObject} remoteObject |
| 1400 */ |
| 1401 _saveToTempVariable: function(remoteObject) |
| 1402 { |
| 1403 WebInspector.runtimeModel.evaluate("window", "", false, true, false, fal
se, didGetGlobalObject); |
| 1404 |
| 1405 /** |
| 1406 * @param {?WebInspector.RemoteObject} global |
| 1407 * @param {boolean=} wasThrown |
| 1408 */ |
| 1409 function didGetGlobalObject(global, wasThrown) |
| 1410 { |
| 1411 /** |
| 1412 * @suppressReceiverCheck |
| 1413 * @this {Window} |
| 1414 */ |
| 1415 function remoteFunction(value) |
| 1416 { |
| 1417 var prefix = "temp"; |
| 1418 var index = 1; |
| 1419 while ((prefix + index) in this) |
| 1420 ++index; |
| 1421 var name = prefix + index; |
| 1422 this[name] = value; |
| 1423 return name; |
| 1424 } |
| 1425 |
| 1426 if (wasThrown || !global) |
| 1427 failedToSave(global); |
| 1428 else |
| 1429 global.callFunction(remoteFunction, [WebInspector.RemoteObject.t
oCallArgument(remoteObject)], didSave.bind(null, global)); |
| 1430 } |
| 1431 |
| 1432 /** |
| 1433 * @param {!WebInspector.RemoteObject} global |
| 1434 * @param {?WebInspector.RemoteObject} result |
| 1435 * @param {boolean=} wasThrown |
| 1436 */ |
| 1437 function didSave(global, result, wasThrown) |
| 1438 { |
| 1439 global.release(); |
| 1440 if (wasThrown || !result || result.type !== "string") |
| 1441 failedToSave(result); |
| 1442 else |
| 1443 WebInspector.console.evaluate(result.value); |
| 1444 } |
| 1445 |
| 1446 /** |
| 1447 * @param {?WebInspector.RemoteObject} result |
| 1448 */ |
| 1449 function failedToSave(result) |
| 1450 { |
| 1451 var message = WebInspector.UIString("Failed to save to temp variable
."); |
| 1452 if (result) { |
| 1453 message += " " + result.description; |
| 1454 result.release(); |
| 1455 } |
| 1456 WebInspector.console.showErrorMessage(message) |
| 1457 } |
| 1458 }, |
| 1459 |
| 1460 /** |
| 1461 * @param {!WebInspector.RemoteObject} remoteObject |
| 1462 */ |
| 1463 _showFunctionDefinition: function(remoteObject) |
| 1464 { |
1396 /** | 1465 /** |
1397 * @param {?Protocol.Error} error | 1466 * @param {?Protocol.Error} error |
1398 * @param {!DebuggerAgent.FunctionDetails} response | 1467 * @param {!DebuggerAgent.FunctionDetails} response |
1399 * @this {WebInspector.SourcesPanel} | 1468 * @this {WebInspector.SourcesPanel} |
1400 */ | 1469 */ |
1401 function didGetDetails(error, response) | 1470 function didGetFunctionDetails(error, response) |
1402 { | 1471 { |
1403 if (error) { | 1472 if (error) { |
1404 console.error(error); | 1473 console.error(error); |
1405 return; | 1474 return; |
1406 } | 1475 } |
1407 | 1476 |
1408 var uiLocation = WebInspector.debuggerModel.rawLocationToUILocation(
response.location); | 1477 var uiLocation = WebInspector.debuggerModel.rawLocationToUILocation(
response.location); |
1409 if (!uiLocation) | 1478 if (!uiLocation) |
1410 return; | 1479 return; |
1411 | 1480 |
1412 this.showUILocation(uiLocation, true); | 1481 this.showUILocation(uiLocation, true); |
1413 } | 1482 } |
1414 | 1483 DebuggerAgent.getFunctionDetails(remoteObject.objectId, didGetFunctionDe
tails.bind(this)); |
1415 /** | |
1416 * @this {WebInspector.SourcesPanel} | |
1417 */ | |
1418 function revealFunction() | |
1419 { | |
1420 DebuggerAgent.getFunctionDetails(remoteObject.objectId, didGetDetail
s.bind(this)); | |
1421 } | |
1422 | |
1423 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe
nuTitles() ? "Show function definition" : "Show Function Definition"), revealFun
ction.bind(this)); | |
1424 }, | 1484 }, |
1425 | 1485 |
1426 /** | 1486 /** |
1427 * @param {string=} query | 1487 * @param {string=} query |
1428 */ | 1488 */ |
1429 _showOpenResourceDialog: function(query) | 1489 _showOpenResourceDialog: function(query) |
1430 { | 1490 { |
1431 var uiSourceCodes = this._editorContainer.historyUISourceCodes(); | 1491 var uiSourceCodes = this._editorContainer.historyUISourceCodes(); |
1432 /** @type {!Map.<!WebInspector.UISourceCode, number>} */ | 1492 /** @type {!Map.<!WebInspector.UISourceCode, number>} */ |
1433 var defaultScores = new Map(); | 1493 var defaultScores = new Map(); |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1716 { | 1776 { |
1717 } | 1777 } |
1718 | 1778 |
1719 WebInspector.SourcesPanel.EditorAction.prototype = { | 1779 WebInspector.SourcesPanel.EditorAction.prototype = { |
1720 /** | 1780 /** |
1721 * @param {!WebInspector.SourcesPanel} panel | 1781 * @param {!WebInspector.SourcesPanel} panel |
1722 * @return {!Element} | 1782 * @return {!Element} |
1723 */ | 1783 */ |
1724 button: function(panel) { } | 1784 button: function(panel) { } |
1725 } | 1785 } |
OLD | NEW |