Commit dde90a00 authored by dpapad's avatar dpapad Committed by Commit Bot

WebUI: Convert Polymer CrPngBehavior to a non-Behavior.

There is no need for this functionality to reside within a Polymer
behavior, and it is already being used a simple class in all call
sites.

This is in preparation of migrating c/b/r/settings/people_page/
to Polymer3.

Bug: 1026426
Change-Id: I9dfbb7bbd2d496f4dcdb6c79df9291d238cae487
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2106916
Commit-Queue: dpapad <dpapad@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751136}
parent e033ca47
...@@ -11,7 +11,6 @@ Polymer({ ...@@ -11,7 +11,6 @@ Polymer({
behaviors: [ behaviors: [
settings.RouteObserverBehavior, settings.RouteObserverBehavior,
CrPngBehavior,
I18nBehavior, I18nBehavior,
WebUIListenerBehavior, WebUIListenerBehavior,
LockStateBehavior, LockStateBehavior,
...@@ -232,8 +231,7 @@ Polymer({ ...@@ -232,8 +231,7 @@ Polymer({
// Extract first frame from image by creating a single frame PNG using // Extract first frame from image by creating a single frame PNG using
// url as input if base64 encoded and potentially animated. // url as input if base64 encoded and potentially animated.
if (info.iconUrl.startsWith('data:image/png;base64')) { if (info.iconUrl.startsWith('data:image/png;base64')) {
this.profileIconUrl_ = this.profileIconUrl_ = cr.png.convertImageSequenceToPng([info.iconUrl]);
CrPngBehavior.convertImageSequenceToPng([info.iconUrl]);
return; return;
} }
this.profileIconUrl_ = info.iconUrl; this.profileIconUrl_ = info.iconUrl;
......
...@@ -12,7 +12,6 @@ Polymer({ ...@@ -12,7 +12,6 @@ Polymer({
behaviors: [ behaviors: [
settings.RouteObserverBehavior, settings.RouteObserverBehavior,
CrPngBehavior,
I18nBehavior, I18nBehavior,
WebUIListenerBehavior, WebUIListenerBehavior,
], ],
...@@ -150,8 +149,8 @@ Polymer({ ...@@ -150,8 +149,8 @@ Polymer({
*/ */
receiveOldImage_(imageInfo) { receiveOldImage_(imageInfo) {
this.oldImageLabel_ = this.i18n( this.oldImageLabel_ = this.i18n(
CrPngBehavior.isEncodedPngDataUrlAnimated(imageInfo.url) ? 'oldVideo' : cr.png.isEncodedPngDataUrlAnimated(imageInfo.url) ? 'oldVideo' :
'oldPhoto'); 'oldPhoto');
this.oldImagePending_ = false; this.oldImagePending_ = false;
this.pictureList_.setOldImageUrl(imageInfo.url, imageInfo.index); this.pictureList_.setOldImageUrl(imageInfo.url, imageInfo.index);
}, },
......
...@@ -11,9 +11,6 @@ Polymer({ ...@@ -11,9 +11,6 @@ Polymer({
behaviors: [ behaviors: [
settings.RouteObserverBehavior, I18nBehavior, WebUIListenerBehavior, settings.RouteObserverBehavior, I18nBehavior, WebUIListenerBehavior,
// <if expr="chromeos">
CrPngBehavior,
// </if>
], ],
properties: { properties: {
...@@ -233,8 +230,7 @@ Polymer({ ...@@ -233,8 +230,7 @@ Polymer({
*/ */
// <if expr="chromeos"> // <if expr="chromeos">
if (info.iconUrl.startsWith('data:image/png;base64')) { if (info.iconUrl.startsWith('data:image/png;base64')) {
this.profileIconUrl_ = this.profileIconUrl_ = cr.png.convertImageSequenceToPng([info.iconUrl]);
CrPngBehavior.convertImageSequenceToPng([info.iconUrl]);
return; return;
} }
// </if> // </if>
......
...@@ -39,4 +39,5 @@ js_library("cr_picture_types") { ...@@ -39,4 +39,5 @@ js_library("cr_picture_types") {
} }
js_library("cr_png_behavior") { js_library("cr_png_behavior") {
deps = [ "//ui/webui/resources/js:cr" ]
} }
...@@ -33,8 +33,6 @@ const CAPTURE_DURATION_MS = 1000; ...@@ -33,8 +33,6 @@ const CAPTURE_DURATION_MS = 1000;
Polymer({ Polymer({
is: 'cr-camera', is: 'cr-camera',
behaviors: [CrPngBehavior],
properties: { properties: {
/** Strings provided by host */ /** Strings provided by host */
takePhotoLabel: String, takePhotoLabel: String,
...@@ -285,8 +283,7 @@ Polymer({ ...@@ -285,8 +283,7 @@ Polymer({
encodedImages.concat(encodedImages.slice(1, -1).reverse()); encodedImages.concat(encodedImages.slice(1, -1).reverse());
/** Convert image sequence to animated PNG. */ /** Convert image sequence to animated PNG. */
return CrPngBehavior.convertImageSequenceToPng( return cr.png.convertImageSequenceToPng(forwardBackwardImageSequence);
forwardBackwardImageSequence);
}, },
/** /**
......
...@@ -12,8 +12,6 @@ ...@@ -12,8 +12,6 @@
Polymer({ Polymer({
is: 'cr-picture-list', is: 'cr-picture-list',
behaviors: [CrPngBehavior],
properties: { properties: {
cameraPresent: Boolean, cameraPresent: Boolean,
...@@ -292,7 +290,7 @@ Polymer({ ...@@ -292,7 +290,7 @@ Polymer({
* url as input if base64 encoded and potentially animated. * url as input if base64 encoded and potentially animated.
*/ */
if (url.split(',')[0] === 'data:image/png;base64') { if (url.split(',')[0] === 'data:image/png;base64') {
return CrPngBehavior.convertImageSequenceToPng([url]); return cr.png.convertImageSequenceToPng([url]);
} }
return url; return url;
......
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
Polymer({ Polymer({
is: 'cr-picture-pane', is: 'cr-picture-pane',
behaviors: [CrPngBehavior],
properties: { properties: {
/** Whether the camera is present / available */ /** Whether the camera is present / available */
...@@ -123,8 +121,8 @@ Polymer({ ...@@ -123,8 +121,8 @@ Polymer({
} }
const blob = new Blob([bytes], {'type': 'image/png'}); const blob = new Blob([bytes], {'type': 'image/png'});
// Use first frame as placeholder while rest of image loads. // Use first frame as placeholder while rest of image loads.
image.style.backgroundImage = 'url(' + image.style.backgroundImage =
CrPngBehavior.convertImageSequenceToPng([this.imageSrc]) + ')'; 'url(' + cr.png.convertImageSequenceToPng([this.imageSrc]) + ')';
this.imageUrl = URL.createObjectURL(blob); this.imageUrl = URL.createObjectURL(blob);
} else { } else {
image.style.backgroundImage = 'none'; image.style.backgroundImage = 'none';
......
<link rel="import" href="../../../html/polymer.html"> <link rel="import" href="../../../html/cr.html">
<script src="cr_png_behavior.js"></script> <script src="cr_png_behavior.js"></script>
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