Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #24287 from ddrmanxbxfr/bug_1005331
Browse files Browse the repository at this point in the history
Bug 1005331 - JSHint fixes for shared/js/media/. r=timdream
  • Loading branch information
BavarianTomcat committed Sep 29, 2014
2 parents eba7fb6 + 22718dc commit b73b27f
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 90 deletions.
7 changes: 0 additions & 7 deletions build/jshint/xfail.list
Expand Up @@ -465,13 +465,6 @@ shared/js/fb/fb_request.js
shared/js/fxa_iac_client.js
shared/js/keyboard_helper.js
shared/js/lockscreen_slide.js
shared/js/media/get_video_rotation.js
shared/js/media/jpeg_metadata_parser.js
shared/js/media/media_frame.js
shared/js/media/media_utils.js
shared/js/media/remote_controls.js
shared/js/media/video_player.js
shared/js/media/video_stats.js
shared/js/mediadb.js
shared/js/operator_variant_helper.js
shared/js/simple_phone_matcher.js
Expand Down
2 changes: 1 addition & 1 deletion shared/js/media/crop_resize_rotate.js
Expand Up @@ -500,7 +500,7 @@ function cropResizeRotate(blob, cropRegion, outputSize, outputType,
// And what part of the canvas we're drawing it to
0, 0, destWidth, destHeight);
}
catch(e) {
catch (e) {
callback('Failed to decode image in cropResizeRotate; ' +
'image may be corrupt or too large: ' + e);
return;
Expand Down
45 changes: 30 additions & 15 deletions shared/js/media/get_video_rotation.js
@@ -1,3 +1,5 @@
/* exported getVideoRotation */
/* global BlobView */
'use strict';

//
Expand Down Expand Up @@ -84,8 +86,9 @@ function getVideoRotation(blob, rotationCallback) {

function parseAtomAt(data, offset) {
if (offset >= blob.size) {
if (handlers.eofHandler)
if (handlers.eofHandler) {
handlers.eofHandler();
}
return;
}
else {
Expand Down Expand Up @@ -119,23 +122,35 @@ function getVideoRotation(blob, rotationCallback) {
var d = data.readUnsignedInt();

if (a === 0 && d === 0) { // 90 or 270 degrees
if (b === 0x00010000 && c === 0xFFFF0000)
if (b === 0x00010000 && c === 0xFFFF0000) {
rotationCallback(90);
else if (b === 0xFFFF0000 && c === 0x00010000)
rotationCallback(270);
else
rotationCallback('unexpected rotation matrix');
}
else if (b === 0 && c === 0) { // 0 or 180 degrees
if (a === 0x00010000 && d === 0x00010000)
rotationCallback(0);
else if (a === 0xFFFF0000 && d === 0xFFFF0000)
rotationCallback(180);
else
rotationCallback('unexpected rotation matrix');
}
else {
if (b === 0xFFFF0000 && c === 0x00010000) {
rotationCallback(270);
}
else {
rotationCallback('unexpected rotation matrix');
}
}
}
else {
rotationCallback('unexpected rotation matrix');
if (b === 0 && c === 0) { // 0 or 180 degrees
if (a === 0x00010000 && d === 0x00010000) {
rotationCallback(0);
}
else {
if (a === 0xFFFF0000 && d === 0xFFFF0000) {
rotationCallback(180);
}
else {
rotationCallback('unexpected rotation matrix');
}
}
}
else {
rotationCallback('unexpected rotation matrix');
}
}
return 'done';
}
Expand Down
17 changes: 11 additions & 6 deletions shared/js/media/jpeg_metadata_parser.js
@@ -1,3 +1,5 @@
/* exported parseJPEGMetadata */
/* global BlobView */
'use strict';

//
Expand Down Expand Up @@ -93,7 +95,7 @@ function parseJPEGMetadata(file, metadataCallback, metadataError) {
break;

case 0xE1: // APP1 segment. Probably holds EXIF metadata
parseAPP1(data);
parseAPP1(data); // jshint ignore:line
/* fallthrough */

default:
Expand Down Expand Up @@ -205,8 +207,9 @@ function parseJPEGMetadata(file, metadataCallback, metadataError) {
var ifd0entries = data.getUint16(offset + 10, byteorder);
var ifd1 = data.getUint32(offset + 12 + 12 * ifd0entries, byteorder);
// If there is an offset for IFD1, parse that
if (ifd1 !== 0)
if (ifd1 !== 0) {
parseIFD(data, ifd1 + 10, byteorder, exif, true);
}

return exif;
}
Expand All @@ -217,8 +220,9 @@ function parseJPEGMetadata(file, metadataCallback, metadataError) {
parseEntry(data, offset + 2 + 12 * i, byteorder, exif);
}

if (onlyParseOne)
if (onlyParseOne) {
return;
}

var next = data.getUint32(offset + 2 + 12 * numentries, byteorder);
if (next !== 0 && next < file.size) {
Expand Down Expand Up @@ -292,8 +296,9 @@ function parseJPEGMetadata(file, metadataCallback, metadataError) {
var tagname = tagnames[tag];

// If we don't know about this tag type or already processed it, skip it
if (!tagname || exif[tagname])
if (!tagname || exif[tagname]) {
return;
}

var type = data.getUint16(offset + 2, byteorder);
var count = data.getUint32(offset + 4, byteorder);
Expand All @@ -317,8 +322,8 @@ function parseJPEGMetadata(file, metadataCallback, metadataError) {
} else {
var values = [];
var size = typesize[type];
for (var i = 0; i < count; i++) {
values[i] = parseOneValue(data, offset + size * i, type, byteorder);
for (var j = 0; j < count; j++) {
values[j] = parseOneValue(data, offset + size * j, type, byteorder);
}
return values;
}
Expand Down

0 comments on commit b73b27f

Please sign in to comment.