| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
| 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 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 view.highlightLine(line); | 362 view.highlightLine(line); |
| 363 } | 363 } |
| 364 return true; | 364 return true; |
| 365 }, | 365 }, |
| 366 | 366 |
| 367 _showResourceView: function(resource) | 367 _showResourceView: function(resource) |
| 368 { | 368 { |
| 369 var view = WebInspector.ResourceManager.resourceViewForResource(resource
); | 369 var view = WebInspector.ResourceManager.resourceViewForResource(resource
); |
| 370 | 370 |
| 371 // Consider rendering diff markup here. | 371 // Consider rendering diff markup here. |
| 372 if (resource._baseRevision && resource.content && view instanceof WebIns
pector.SourceView) { | 372 if (resource.baseRevision && view instanceof WebInspector.SourceView) { |
| 373 function callback(baseContent) | 373 function callback(baseContent) |
| 374 { | 374 { |
| 375 if (baseContent) | 375 if (baseContent) |
| 376 this._applyDiffMarkup(view, baseContent, resource.content); | 376 this._applyDiffMarkup(view, baseContent, resource.content); |
| 377 } | 377 } |
| 378 resource._baseRevision.requestContent(callback.bind(this)); | 378 resource.baseRevision.requestContent(callback.bind(this)); |
| 379 } | 379 } |
| 380 this._innerShowView(view); | 380 this._innerShowView(view); |
| 381 }, | 381 }, |
| 382 | 382 |
| 383 _applyDiffMarkup: function(view, baseContent, newContent) { | 383 _applyDiffMarkup: function(view, baseContent, newContent) { |
| 384 var oldLines = baseContent.split("\n"); | 384 var oldLines = baseContent.split("\n"); |
| 385 var newLines = newContent.split("\n"); | 385 var newLines = newContent.split("\n"); |
| 386 | 386 |
| 387 var diff = Array.diff(oldLines, newLines); | 387 var diff = Array.diff(oldLines, newLines); |
| 388 | 388 |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 | 1084 |
| 1085 if (this._resource.warnings) | 1085 if (this._resource.warnings) |
| 1086 this._bubbleElement.addStyleClass("warning"); | 1086 this._bubbleElement.addStyleClass("warning"); |
| 1087 | 1087 |
| 1088 if (this._resource.errors) | 1088 if (this._resource.errors) |
| 1089 this._bubbleElement.addStyleClass("error"); | 1089 this._bubbleElement.addStyleClass("error"); |
| 1090 }, | 1090 }, |
| 1091 | 1091 |
| 1092 _contentChanged: function(event) | 1092 _contentChanged: function(event) |
| 1093 { | 1093 { |
| 1094 var revisionResource = new WebInspector.Resource(null, this._resource.ur
l); | 1094 this.insertChild(new WebInspector.ResourceRevisionTreeElement(this._stor
agePanel, event.data.revision), 0); |
| 1095 revisionResource.type = this._resource.type; | |
| 1096 revisionResource.loader = this._resource.loader; | |
| 1097 if (this._resource.finished) | |
| 1098 revisionResource.finished = true; | |
| 1099 else { | |
| 1100 function finished() | |
| 1101 { | |
| 1102 revisionResource.finished = true; | |
| 1103 } | |
| 1104 this._resource.addEventListener("finished", finished); | |
| 1105 } | |
| 1106 | |
| 1107 if (!this._resource._baseRevision) | |
| 1108 this._resource._baseRevision = revisionResource; | |
| 1109 else | |
| 1110 revisionResource._baseRevision = this._resource._baseRevision; | |
| 1111 | |
| 1112 if (event.data.oldContent) | |
| 1113 revisionResource.setInitialContent(event.data.oldContent); | |
| 1114 this.insertChild(new WebInspector.ResourceRevisionTreeElement(this._stor
agePanel, revisionResource, event.data.oldContentTimestamp), 0); | |
| 1115 | |
| 1116 var oldView = WebInspector.ResourceManager.existingResourceViewForResour
ce(this._resource); | 1095 var oldView = WebInspector.ResourceManager.existingResourceViewForResour
ce(this._resource); |
| 1117 if (oldView) { | 1096 if (oldView) { |
| 1118 var newView = WebInspector.ResourceManager.recreateResourceView(this
._resource); | 1097 var newView = WebInspector.ResourceManager.recreateResourceView(this
._resource); |
| 1119 if (oldView === this._storagePanel.visibleView) | 1098 if (oldView === this._storagePanel.visibleView) |
| 1120 this._storagePanel.visibleView = newView; | 1099 this._storagePanel.visibleView = newView; |
| 1121 } | 1100 } |
| 1122 } | 1101 } |
| 1123 } | 1102 } |
| 1124 | 1103 |
| 1125 WebInspector.FrameResourceTreeElement.prototype.__proto__ = WebInspector.BaseSto
rageTreeElement.prototype; | 1104 WebInspector.FrameResourceTreeElement.prototype.__proto__ = WebInspector.BaseSto
rageTreeElement.prototype; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 }, | 1218 }, |
| 1240 | 1219 |
| 1241 onselect: function() | 1220 onselect: function() |
| 1242 { | 1221 { |
| 1243 WebInspector.BaseStorageTreeElement.prototype.onselect.call(this); | 1222 WebInspector.BaseStorageTreeElement.prototype.onselect.call(this); |
| 1244 this._storagePanel.showApplicationCache(this, this._appcacheDomain); | 1223 this._storagePanel.showApplicationCache(this, this._appcacheDomain); |
| 1245 } | 1224 } |
| 1246 } | 1225 } |
| 1247 WebInspector.ApplicationCacheTreeElement.prototype.__proto__ = WebInspector.Base
StorageTreeElement.prototype; | 1226 WebInspector.ApplicationCacheTreeElement.prototype.__proto__ = WebInspector.Base
StorageTreeElement.prototype; |
| 1248 | 1227 |
| 1249 WebInspector.ResourceRevisionTreeElement = function(storagePanel, resource, time
stamp) | 1228 WebInspector.ResourceRevisionTreeElement = function(storagePanel, revision) |
| 1250 { | 1229 { |
| 1251 var title = timestamp ? timestamp.toLocaleTimeString() : "(original)"; | 1230 var title = revision.timestamp ? revision.timestamp.toLocaleTimeString() : "
(original)"; |
| 1252 WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, title, "r
esource-sidebar-tree-item resources-category-" + resource.category.name); | 1231 WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, title, "r
esource-sidebar-tree-item resources-category-" + revision.category.name); |
| 1253 if (timestamp) | 1232 if (revision.timestamp) |
| 1254 this.tooltip = timestamp.toLocaleString(); | 1233 this.tooltip = revision.timestamp.toLocaleString(); |
| 1255 this._resource = resource; | 1234 this._resource = revision; |
| 1256 } | 1235 } |
| 1257 | 1236 |
| 1258 WebInspector.ResourceRevisionTreeElement.prototype = { | 1237 WebInspector.ResourceRevisionTreeElement.prototype = { |
| 1259 onattach: function() | 1238 onattach: function() |
| 1260 { | 1239 { |
| 1261 WebInspector.BaseStorageTreeElement.prototype.onattach.call(this); | 1240 WebInspector.BaseStorageTreeElement.prototype.onattach.call(this); |
| 1262 this.listItemElement.draggable = true; | 1241 this.listItemElement.draggable = true; |
| 1263 this.listItemElement.addEventListener("dragstart", this._ondragstart.bin
d(this), false); | 1242 this.listItemElement.addEventListener("dragstart", this._ondragstart.bin
d(this), false); |
| 1243 this.listItemElement.addEventListener("contextmenu", this._handleContext
MenuEvent.bind(this), true); |
| 1264 }, | 1244 }, |
| 1265 | 1245 |
| 1266 onselect: function() | 1246 onselect: function() |
| 1267 { | 1247 { |
| 1268 WebInspector.BaseStorageTreeElement.prototype.onselect.call(this); | 1248 WebInspector.BaseStorageTreeElement.prototype.onselect.call(this); |
| 1269 this._storagePanel._showResourceView(this._resource); | 1249 this._storagePanel._showResourceView(this._resource); |
| 1270 }, | 1250 }, |
| 1271 | 1251 |
| 1272 _ondragstart: function(event) | 1252 _ondragstart: function(event) |
| 1273 { | 1253 { |
| 1274 event.dataTransfer.setData("text/plain", this._resource.content); | 1254 event.dataTransfer.setData("text/plain", this._resource.content); |
| 1275 event.dataTransfer.effectAllowed = "copy"; | 1255 event.dataTransfer.effectAllowed = "copy"; |
| 1276 return true; | 1256 return true; |
| 1257 }, |
| 1258 |
| 1259 _handleContextMenuEvent: function(event) |
| 1260 { |
| 1261 var contextMenu = new WebInspector.ContextMenu(); |
| 1262 contextMenu.appendItem(WebInspector.UIString("Revert to this revision"),
this._resource.revertToThis.bind(this._resource)); |
| 1263 contextMenu.show(event); |
| 1277 } | 1264 } |
| 1278 } | 1265 } |
| 1279 | 1266 |
| 1280 WebInspector.ResourceRevisionTreeElement.prototype.__proto__ = WebInspector.Base
StorageTreeElement.prototype; | 1267 WebInspector.ResourceRevisionTreeElement.prototype.__proto__ = WebInspector.Base
StorageTreeElement.prototype; |
| 1281 | 1268 |
| 1282 WebInspector.FileSystemTreeElement = function(storagePanel, origin) | 1269 WebInspector.FileSystemTreeElement = function(storagePanel, origin) |
| 1283 { | 1270 { |
| 1284 WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, origin, "
file-system-storage-tree-item"); | 1271 WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, origin, "
file-system-storage-tree-item"); |
| 1285 this._origin = origin; | 1272 this._origin = origin; |
| 1286 } | 1273 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1312 } | 1299 } |
| 1313 | 1300 |
| 1314 WebInspector.StorageCategoryView.prototype = { | 1301 WebInspector.StorageCategoryView.prototype = { |
| 1315 setText: function(text) | 1302 setText: function(text) |
| 1316 { | 1303 { |
| 1317 this._emptyMsgElement.textContent = text; | 1304 this._emptyMsgElement.textContent = text; |
| 1318 } | 1305 } |
| 1319 } | 1306 } |
| 1320 | 1307 |
| 1321 WebInspector.StorageCategoryView.prototype.__proto__ = WebInspector.View.prototy
pe; | 1308 WebInspector.StorageCategoryView.prototype.__proto__ = WebInspector.View.prototy
pe; |
| OLD | NEW |