| Index: third_party/WebKit/Source/devtools/front_end/source_frame/ImageView.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/source_frame/ImageView.js b/third_party/WebKit/Source/devtools/front_end/source_frame/ImageView.js
|
| index 56d63ef3ef5dbf9a2bb9383a6638236692a19f63..7b43e03df939fe4562bdfd1aae9706382ba9ec2e 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/source_frame/ImageView.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/source_frame/ImageView.js
|
| @@ -25,18 +25,18 @@
|
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
| * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
| -
|
| /**
|
| - * @extends {WebInspector.SimpleView}
|
| - * @constructor
|
| - * @param {string} mimeType
|
| - * @param {!WebInspector.ContentProvider} contentProvider
|
| + * @unrestricted
|
| */
|
| -WebInspector.ImageView = function(mimeType, contentProvider)
|
| -{
|
| - WebInspector.SimpleView.call(this, WebInspector.UIString("Image"));
|
| - this.registerRequiredCSS("source_frame/imageView.css");
|
| - this.element.classList.add("image-view");
|
| +WebInspector.ImageView = class extends WebInspector.SimpleView {
|
| + /**
|
| + * @param {string} mimeType
|
| + * @param {!WebInspector.ContentProvider} contentProvider
|
| + */
|
| + constructor(mimeType, contentProvider) {
|
| + super(WebInspector.UIString('Image'));
|
| + this.registerRequiredCSS('source_frame/imageView.css');
|
| + this.element.classList.add('image-view');
|
| this._url = contentProvider.contentURL();
|
| this._parsedURL = new WebInspector.ParsedURL(this._url);
|
| this._mimeType = mimeType;
|
| @@ -44,100 +44,95 @@ WebInspector.ImageView = function(mimeType, contentProvider)
|
| this._sizeLabel = new WebInspector.ToolbarText();
|
| this._dimensionsLabel = new WebInspector.ToolbarText();
|
| this._mimeTypeLabel = new WebInspector.ToolbarText(mimeType);
|
| -};
|
| -
|
| -WebInspector.ImageView.prototype = {
|
| - /**
|
| - * @override
|
| - * @return {!Array<!WebInspector.ToolbarItem>}
|
| - */
|
| - syncToolbarItems: function()
|
| - {
|
| - return [this._sizeLabel, new WebInspector.ToolbarSeparator(), this._dimensionsLabel, new WebInspector.ToolbarSeparator(), this._mimeTypeLabel];
|
| - },
|
| + }
|
|
|
| - wasShown: function()
|
| - {
|
| - this._createContentIfNeeded();
|
| - },
|
| + /**
|
| + * @override
|
| + * @return {!Array<!WebInspector.ToolbarItem>}
|
| + */
|
| + syncToolbarItems() {
|
| + return [
|
| + this._sizeLabel, new WebInspector.ToolbarSeparator(), this._dimensionsLabel, new WebInspector.ToolbarSeparator(),
|
| + this._mimeTypeLabel
|
| + ];
|
| + }
|
|
|
| - _createContentIfNeeded: function()
|
| - {
|
| - if (this._container)
|
| - return;
|
| + /**
|
| + * @override
|
| + */
|
| + wasShown() {
|
| + this._createContentIfNeeded();
|
| + }
|
|
|
| - this._container = this.element.createChild("div", "image");
|
| - var imagePreviewElement = this._container.createChild("img", "resource-image-view");
|
| - imagePreviewElement.addEventListener("contextmenu", this._contextMenu.bind(this), true);
|
| + _createContentIfNeeded() {
|
| + if (this._container)
|
| + return;
|
|
|
| - this._contentProvider.requestContent().then(onContentAvailable.bind(this));
|
| + this._container = this.element.createChild('div', 'image');
|
| + var imagePreviewElement = this._container.createChild('img', 'resource-image-view');
|
| + imagePreviewElement.addEventListener('contextmenu', this._contextMenu.bind(this), true);
|
|
|
| - /**
|
| - * @param {?string} content
|
| - * @this {WebInspector.ImageView}
|
| - */
|
| - function onContentAvailable(content)
|
| - {
|
| - var imageSrc = WebInspector.ContentProvider.contentAsDataURL(content, this._mimeType, true);
|
| - if (imageSrc === null)
|
| - imageSrc = this._url;
|
| - imagePreviewElement.src = imageSrc;
|
| - this._sizeLabel.setText(Number.bytesToString(this._base64ToSize(content)));
|
| - this._dimensionsLabel.setText(WebInspector.UIString("%d × %d", imagePreviewElement.naturalWidth, imagePreviewElement.naturalHeight));
|
| - }
|
| - this._imagePreviewElement = imagePreviewElement;
|
| - },
|
| + this._contentProvider.requestContent().then(onContentAvailable.bind(this));
|
|
|
| /**
|
| * @param {?string} content
|
| - * @return {number}
|
| + * @this {WebInspector.ImageView}
|
| */
|
| - _base64ToSize: function(content)
|
| - {
|
| - if (!content || !content.length)
|
| - return 0;
|
| - var size = (content.length || 0) * 3 / 4;
|
| - if (content.length > 0 && content[content.length - 1] === "=")
|
| - size--;
|
| - if (content.length > 1 && content[content.length - 2] === "=")
|
| - size--;
|
| - return size;
|
| - },
|
| + function onContentAvailable(content) {
|
| + var imageSrc = WebInspector.ContentProvider.contentAsDataURL(content, this._mimeType, true);
|
| + if (imageSrc === null)
|
| + imageSrc = this._url;
|
| + imagePreviewElement.src = imageSrc;
|
| + this._sizeLabel.setText(Number.bytesToString(this._base64ToSize(content)));
|
| + this._dimensionsLabel.setText(
|
| + WebInspector.UIString('%d × %d', imagePreviewElement.naturalWidth, imagePreviewElement.naturalHeight));
|
| + }
|
| + this._imagePreviewElement = imagePreviewElement;
|
| + }
|
|
|
| - _contextMenu: function(event)
|
| - {
|
| - var contextMenu = new WebInspector.ContextMenu(event);
|
| - if (!this._parsedURL.isDataURL())
|
| - contextMenu.appendItem(WebInspector.UIString.capitalize("Copy ^image URL"), this._copyImageURL.bind(this));
|
| - if (this._imagePreviewElement.src)
|
| - contextMenu.appendItem(WebInspector.UIString.capitalize("Copy ^image as Data URI"), this._copyImageAsDataURL.bind(this));
|
| - contextMenu.appendItem(WebInspector.UIString.capitalize("Open ^image in ^new ^tab"), this._openInNewTab.bind(this));
|
| - contextMenu.appendItem(WebInspector.UIString.capitalize("Save\u2026"), this._saveImage.bind(this));
|
| - contextMenu.show();
|
| - },
|
| + /**
|
| + * @param {?string} content
|
| + * @return {number}
|
| + */
|
| + _base64ToSize(content) {
|
| + if (!content || !content.length)
|
| + return 0;
|
| + var size = (content.length || 0) * 3 / 4;
|
| + if (content.length > 0 && content[content.length - 1] === '=')
|
| + size--;
|
| + if (content.length > 1 && content[content.length - 2] === '=')
|
| + size--;
|
| + return size;
|
| + }
|
|
|
| - _copyImageAsDataURL: function()
|
| - {
|
| - InspectorFrontendHost.copyText(this._imagePreviewElement.src);
|
| - },
|
| + _contextMenu(event) {
|
| + var contextMenu = new WebInspector.ContextMenu(event);
|
| + if (!this._parsedURL.isDataURL())
|
| + contextMenu.appendItem(WebInspector.UIString.capitalize('Copy ^image URL'), this._copyImageURL.bind(this));
|
| + if (this._imagePreviewElement.src)
|
| + contextMenu.appendItem(
|
| + WebInspector.UIString.capitalize('Copy ^image as Data URI'), this._copyImageAsDataURL.bind(this));
|
| + contextMenu.appendItem(WebInspector.UIString.capitalize('Open ^image in ^new ^tab'), this._openInNewTab.bind(this));
|
| + contextMenu.appendItem(WebInspector.UIString.capitalize('Save\u2026'), this._saveImage.bind(this));
|
| + contextMenu.show();
|
| + }
|
|
|
| - _copyImageURL: function()
|
| - {
|
| - InspectorFrontendHost.copyText(this._url);
|
| - },
|
| + _copyImageAsDataURL() {
|
| + InspectorFrontendHost.copyText(this._imagePreviewElement.src);
|
| + }
|
|
|
| - _saveImage: function()
|
| - {
|
| - var link = createElement("a");
|
| - link.download = this._parsedURL.displayName;
|
| - link.href = this._url;
|
| - link.click();
|
| - },
|
| + _copyImageURL() {
|
| + InspectorFrontendHost.copyText(this._url);
|
| + }
|
|
|
| - _openInNewTab: function()
|
| - {
|
| - InspectorFrontendHost.openInNewTab(this._url);
|
| - },
|
| + _saveImage() {
|
| + var link = createElement('a');
|
| + link.download = this._parsedURL.displayName;
|
| + link.href = this._url;
|
| + link.click();
|
| + }
|
|
|
| - __proto__: WebInspector.SimpleView.prototype
|
| + _openInNewTab() {
|
| + InspectorFrontendHost.openInNewTab(this._url);
|
| + }
|
| };
|
|
|