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 #11734 from davidflanagan/bug903944-v1-train
Browse files Browse the repository at this point in the history
Bug903944 v1 train
  • Loading branch information
David Flanagan committed Aug 24, 2013
2 parents 29a8397 + 53b2e95 commit 4b2f1a1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apps/gallery/js/MetadataParser.js
Expand Up @@ -202,7 +202,7 @@ var metadataParser = (function() {
// If the preview is big enough, use it to create a thumbnail.
// A preview is big enough if at least one dimension is >= the
// screen size in both portait and landscape mode.
if ((pw >= sw || pw >= sh) && (pw >= sh || ph >= sw)) {
if ((pw >= sw || ph >= sh) && (pw >= sh || ph >= sw)) {
// The final argument true means don't actually create a preview
createThumbnailAndPreview(previewblob,
function(m) {
Expand Down
20 changes: 18 additions & 2 deletions apps/gallery/js/open.js
Expand Up @@ -61,8 +61,24 @@ window.addEventListener('localized', function() {
// We'll enable it below in the open() function if needed.
$('menu').hidden = true;

blob = activityData.blob;
open(blob);
// Make a local copy of the blob before opening it to workaround bug 908432
copyBlob(activityData.blob, function(localCopy) {
blob = localCopy;
open(blob);
});
}

// Read the content of a (possibly file-backed, cross-process) blob into an
// array buffer, and then create a new in-memory, in process blob from
// that array buffer. This is part of the workaround for the crash in
// bug 908432.
function copyBlob(original, callback) {
var reader = new FileReader();
reader.readAsArrayBuffer(original);
reader.onload = function() {
var copy = new Blob([reader.result], { type: original.type });
callback(copy);
};
}

// Display the specified blob, unless it is too big to display
Expand Down
15 changes: 14 additions & 1 deletion shared/js/media/media_frame.js
Expand Up @@ -70,9 +70,22 @@ MediaFrame.prototype.displayImage = function displayImage(blob, width, height,
// Make the image element visible
this.image.style.display = 'block';

function bigEnough(preview) {
if (!preview.width || !preview.height)
return false;

// A preview is big enough if at least one dimension is >= the
// screen size in both portait and landscape mode.
var sw = window.innerWidth;
var sh = window.innerHeight;

return ((preview.width >= sw || preview.height >= sh) && // portrait
(preview.width >= sh || preview.height >= sw)); // landscape
}

// If the preview is at least as big as the screen, display that.
// Otherwise, display the full-size image.
if (preview && (preview.start || preview.filename)) {
if (preview && (preview.start || preview.filename) && bigEnough(preview)) {
this.displayingPreview = true;
if (preview.start) {
this.previewblob = blob.slice(preview.start, preview.end, 'image/jpeg');
Expand Down

0 comments on commit 4b2f1a1

Please sign in to comment.