| 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) 2007, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
| 4 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> | 4 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 152 |
| 153 /** | 153 /** |
| 154 * @param {!WebInspector.Target} target | 154 * @param {!WebInspector.Target} target |
| 155 * @param {string} originalImageURL | 155 * @param {string} originalImageURL |
| 156 * @param {boolean} showDimensions | 156 * @param {boolean} showDimensions |
| 157 * @param {function(!Element=)} userCallback | 157 * @param {function(!Element=)} userCallback |
| 158 * @param {!Object=} precomputedFeatures | 158 * @param {!Object=} precomputedFeatures |
| 159 */ | 159 */ |
| 160 WebInspector.DOMPresentationUtils.buildImagePreviewContents = function(target, o
riginalImageURL, showDimensions, userCallback, precomputedFeatures) | 160 WebInspector.DOMPresentationUtils.buildImagePreviewContents = function(target, o
riginalImageURL, showDimensions, userCallback, precomputedFeatures) |
| 161 { | 161 { |
| 162 var resource = target.resourceTreeModel.resourceForURL(originalImageURL); | 162 var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(target); |
| 163 if (!resourceTreeModel) { |
| 164 userCallback(); |
| 165 return; |
| 166 } |
| 167 var resource = resourceTreeModel.resourceForURL(originalImageURL); |
| 163 var imageURL = originalImageURL; | 168 var imageURL = originalImageURL; |
| 164 if (!isImageResource(resource) && precomputedFeatures && precomputedFeatures
.currentSrc) { | 169 if (!isImageResource(resource) && precomputedFeatures && precomputedFeatures
.currentSrc) { |
| 165 imageURL = precomputedFeatures.currentSrc; | 170 imageURL = precomputedFeatures.currentSrc; |
| 166 resource = target.resourceTreeModel.resourceForURL(imageURL); | 171 resource = resourceTreeModel.resourceForURL(imageURL); |
| 167 } | 172 } |
| 168 if (!isImageResource(resource)) { | 173 if (!isImageResource(resource)) { |
| 169 userCallback(); | 174 userCallback(); |
| 170 return; | 175 return; |
| 171 } | 176 } |
| 172 | 177 |
| 173 var imageElement = createElement("img"); | 178 var imageElement = createElement("img"); |
| 174 imageElement.addEventListener("load", buildContent, false); | 179 imageElement.addEventListener("load", buildContent, false); |
| 175 imageElement.addEventListener("error", errorCallback, false); | 180 imageElement.addEventListener("error", errorCallback, false); |
| 176 resource.populateImageSource(imageElement); | 181 resource.populateImageSource(imageElement); |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 /** | 658 /** |
| 654 * @override | 659 * @override |
| 655 * @param {!WebInspector.DOMNode} node | 660 * @param {!WebInspector.DOMNode} node |
| 656 * @return {?{title: string, color: string}} | 661 * @return {?{title: string, color: string}} |
| 657 */ | 662 */ |
| 658 decorate: function(node) | 663 decorate: function(node) |
| 659 { | 664 { |
| 660 return { title: this._title, color: this._color }; | 665 return { title: this._title, color: this._color }; |
| 661 } | 666 } |
| 662 } | 667 } |
| OLD | NEW |