Title: [214436] trunk/Source/WebInspectorUI
- Revision
- 214436
- Author
- [email protected]
- Date
- 2017-03-27 16:19:21 -0700 (Mon, 27 Mar 2017)
Log Message
Web Inspector: Resource Details Sidebar displays previous image metrics when viewing resource where content load failed
https://bugs.webkit.org/show_bug.cgi?id=170065
<rdar://problem/27081591>
Patch by Joseph Pecoraro <[email protected]> on 2017-03-27
Reviewed by Matt Baker.
* UserInterface/Models/Resource.js:
(WebInspector.Resource.prototype.getImageSize.imageDidLoad):
(WebInspector.Resource.prototype.getImageSize.requestContentFailure):
(WebInspector.Resource.prototype.getImageSize):
If the requestContent failed, return a null image size.
* UserInterface/Views/ResourceDetailsSidebarPanel.js:
(WebInspector.ResourceDetailsSidebarPanel.prototype._refreshImageSizeSection.hideImageSection):
(WebInspector.ResourceDetailsSidebarPanel.prototype._refreshImageSizeSection):
If the callback is called with a null size, hide the image size section.
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (214435 => 214436)
--- trunk/Source/WebInspectorUI/ChangeLog 2017-03-27 22:56:32 UTC (rev 214435)
+++ trunk/Source/WebInspectorUI/ChangeLog 2017-03-27 23:19:21 UTC (rev 214436)
@@ -1,3 +1,22 @@
+2017-03-27 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: Resource Details Sidebar displays previous image metrics when viewing resource where content load failed
+ https://bugs.webkit.org/show_bug.cgi?id=170065
+ <rdar://problem/27081591>
+
+ Reviewed by Matt Baker.
+
+ * UserInterface/Models/Resource.js:
+ (WebInspector.Resource.prototype.getImageSize.imageDidLoad):
+ (WebInspector.Resource.prototype.getImageSize.requestContentFailure):
+ (WebInspector.Resource.prototype.getImageSize):
+ If the requestContent failed, return a null image size.
+
+ * UserInterface/Views/ResourceDetailsSidebarPanel.js:
+ (WebInspector.ResourceDetailsSidebarPanel.prototype._refreshImageSizeSection.hideImageSection):
+ (WebInspector.ResourceDetailsSidebarPanel.prototype._refreshImageSizeSection):
+ If the callback is called with a null size, hide the image size section.
+
2017-03-24 Brian Burg <[email protected]>
Web Inspector: RTL: number scripts are used inconsistently throughout the UI
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js (214435 => 214436)
--- trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js 2017-03-27 22:56:32 UTC (rev 214435)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js 2017-03-27 23:19:21 UTC (rev 214436)
@@ -694,7 +694,7 @@
// See if we've already computed and cached the image size,
// in which case we can provide them directly.
- if (this._imageSize) {
+ if (this._imageSize !== undefined) {
callback(this._imageSize);
return;
}
@@ -702,8 +702,7 @@
var objectURL = null;
// Event handler for the image "load" event.
- function imageDidLoad()
- {
+ function imageDidLoad() {
URL.revokeObjectURL(objectURL);
// Cache the image metrics.
@@ -715,6 +714,11 @@
callback(this._imageSize);
}
+ function requestContentFailure() {
+ this._imageSize = null;
+ callback(this._imageSize);
+ }
+
// Create an <img> element that we'll use to load the image resource
// so that we can query its intrinsic size.
var image = new Image;
@@ -723,7 +727,7 @@
// Set the image source using an object URL once we've obtained its data.
this.requestContent().then(function(content) {
objectURL = image.src = ""
- });
+ }, requestContentFailure.bind(this));
}
requestContent()
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceDetailsSidebarPanel.js (214435 => 214436)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceDetailsSidebarPanel.js 2017-03-27 22:56:32 UTC (rev 214435)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceDetailsSidebarPanel.js 2017-03-27 23:19:21 UTC (rev 214436)
@@ -434,11 +434,15 @@
if (!resource)
return;
+ function hideImageSection() {
+ let imageSectionElement = this._imageSizeSection.element;
+ if (imageSectionElement.parentNode)
+ this.contentView.element.removeChild(imageSectionElement);
+ }
+
// Hide the section if we're not dealing with an image or if the load failed.
if (resource.type !== WebInspector.Resource.Type.Image || resource.failed) {
- var imageSectionElement = this._imageSizeSection.element;
- if (imageSectionElement.parentNode)
- this.contentView.element.removeChild(imageSectionElement);
+ hideImageSection.call(this);
return;
}
@@ -447,8 +451,11 @@
// Get the metrics for this resource and fill in the metrics rows with that information.
resource.getImageSize((size) => {
- this._imageWidthRow.value = WebInspector.UIString("%dpx").format(size.width);
- this._imageHeightRow.value = WebInspector.UIString("%dpx").format(size.height);
+ if (size) {
+ this._imageWidthRow.value = WebInspector.UIString("%dpx").format(size.width);
+ this._imageHeightRow.value = WebInspector.UIString("%dpx").format(size.height);
+ } else
+ hideImageSection.call(this);
});
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes