Commit 8bbd4d70 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[quickview] Use polymer setProperties() to clear the metadata box

Change the QuickView metadata box custom element clear() method to use
Polymer this.setProperties() which can set multiple element properties
with one function call.

Create a local reset Object, containing the properties to change, then
call this.setProperties(reset) to apply those changes.

Per lucmult@ CL:1937949, it is 25-33% faster, compared to setting each
property value, one after the other as in the code before this CL.

Bug: 1029211
Change-Id: Ia00f334a5f2394546ce0395fd654c0017f5354a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1941531Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719933}
parent 67ee9db3
...@@ -72,6 +72,7 @@ js_unittest("files_message_unittest") { ...@@ -72,6 +72,7 @@ js_unittest("files_message_unittest") {
} }
js_library("files_metadata_box") { js_library("files_metadata_box") {
externs_list = [ "$externs_path/pending_polymer.js" ]
} }
js_library("files_metadata_entry") { js_library("files_metadata_entry") {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
var FilesMetadataBox = Polymer({ const FilesMetadataBox = Polymer({
is: 'files-metadata-box', is: 'files-metadata-box',
properties: { properties: {
...@@ -53,30 +53,31 @@ var FilesMetadataBox = Polymer({ ...@@ -53,30 +53,31 @@ var FilesMetadataBox = Polymer({
* @param {boolean} keepSizeFields do not clear size and isSizeLoading fields. * @param {boolean} keepSizeFields do not clear size and isSizeLoading fields.
*/ */
clear: function(keepSizeFields) { clear: function(keepSizeFields) {
this.filePath = ''; const reset = {
this.metadata = ''; type: '',
filePath: '',
modificationTime: '',
hasFileSpecificMetadata_: false,
mediaMimeType: '',
ifd: null,
imageWidth: 0,
imageHeight: 0,
mediaTitle: '',
mediaArtist: '',
mediaAlbum: '',
mediaDuration: 0,
mediaGenre: '',
mediaTrack: '',
mediaYearRecorded: '',
metadata: '',
};
if (!keepSizeFields) { if (!keepSizeFields) {
this.size = ''; reset.isSizeLoading = false;
this.isSizeLoading = false; reset.size = '';
} }
this.modificationTime = '';
this.mediaMimeType = '';
this.type = '';
this.hasFileSpecificMetadata_ = false;
/** @type {?Object} */ this.setProperties(reset);
this.ifd = null;
this.imageWidth = 0;
this.imageHeight = 0;
this.mediaTitle = '';
this.mediaArtist = '';
this.mediaAlbum = '';
this.mediaDuration = 0;
this.mediaGenre = '';
this.mediaTrack = '';
this.mediaYearRecorded = '';
}, },
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment