Skip to content

Commit 296b98f

Browse files
committed
Merge branch 'master' of git://github.com/mozilla/pdf.js.git into progress-indeterminate
Conflicts: extensions/firefox/components/PdfStreamConverter.js
2 parents cd1a645 + 62e6b43 commit 296b98f

File tree

3 files changed

+85
-66
lines changed

3 files changed

+85
-66
lines changed

extensions/firefox/components/PdfStreamConverter.js

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -131,30 +131,28 @@ function PdfDataListener(length) {
131131
}
132132

133133
PdfDataListener.prototype = {
134-
set: function PdfDataListener_set(chunk, offset) {
135-
if (this.length < 0) {
136-
var willBeLoaded = this.loaded + chunk.length;
134+
append: function PdfDataListener_append(chunk) {
135+
var willBeLoaded = this.loaded + chunk.length;
136+
if (this.length >= 0 && this.length < willBeLoaded) {
137+
this.length = -1; // reset the length, server is giving incorrect one
138+
}
139+
if (this.length < 0 && this.data.length < willBeLoaded) {
137140
// data length is unknown and new chunk will not fit in the existing
138141
// buffer, resizing the buffer by doubling the its last length
139-
if (this.data.length < willBeLoaded) {
140-
var newLength = this.data.length;
141-
for (; newLength < willBeLoaded; newLength *= 2) {}
142-
var newData = new Uint8Array(newLength);
143-
newData.set(this.data);
144-
this.data = newData;
145-
}
146-
this.data.set(chunk, this.loaded);
147-
this.loaded = willBeLoaded;
148-
this.onprogress(this.loaded);
149-
} else {
150-
this.data.set(chunk, offset);
151-
this.loaded = offset + chunk.length;
152-
this.onprogress(this.loaded, this.length);
142+
var newLength = this.data.length;
143+
for (; newLength < willBeLoaded; newLength *= 2) {}
144+
var newData = new Uint8Array(newLength);
145+
newData.set(this.data);
146+
this.data = newData;
153147
}
148+
this.data.set(chunk, this.loaded);
149+
this.loaded = willBeLoaded;
150+
this.onprogress(this.loaded, this.length >= 0 ? this.length : void(0));
154151
},
155152
getData: function PdfDataListener_getData() {
156-
var data = this.length >= 0 ? this.data :
157-
this.data.subarray(0, this.loaded);
153+
var data = this.data;
154+
if (this.loaded != data.length)
155+
data = data.subarray(0, this.loaded);
158156
delete this.data; // releasing temporary storage
159157
return data;
160158
},
@@ -463,7 +461,7 @@ PdfStreamConverter.prototype = {
463461

464462
var binaryStream = this.binaryStream;
465463
binaryStream.setInputStream(aInputStream);
466-
this.dataListener.set(binaryStream.readByteArray(aCount), aOffset);
464+
this.dataListener.append(binaryStream.readByteArray(aCount));
467465
},
468466

469467
// nsIRequestObserver::onStartRequest

make.js

Lines changed: 66 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env node
21
require('./external/shelljs/make');
32
var builder = require('./external/builder/builder.js');
43
var crlfchecker = require('./external/crlfchecker/crlfchecker.js');
@@ -92,8 +91,9 @@ target.generic = function() {
9291

9392
//
9493
// make web
95-
// Generates the website for the project, by checking out the gh-pages branch underneath
96-
// the build directory, and then moving the various viewer files into place.
94+
// Generates the website for the project, by checking out the gh-pages branch
95+
// underneath the build directory, and then moving the various viewer files
96+
// into place.
9797
//
9898
target.web = function() {
9999
target.generic();
@@ -113,9 +113,9 @@ target.web = function() {
113113
exec('git add -A');
114114

115115
echo();
116-
echo("Website built in " + GH_PAGES_DIR);
117-
echo("Don't forget to cd into " + GH_PAGES_DIR +
118-
" and issue 'git commit' to push changes.");
116+
echo('Website built in ' + GH_PAGES_DIR);
117+
echo('Don\'t forget to cd into ' + GH_PAGES_DIR +
118+
' and issue \'git commit\' to push changes.');
119119
};
120120

121121
//
@@ -153,7 +153,8 @@ target.locale = function() {
153153
}
154154

155155
mkdir('-p', EXTENSION_LOCALE_OUTPUT + '/' + locale);
156-
chromeManifestContent += 'locale pdf.js ' + locale + ' locale/' + locale + '/\n';
156+
chromeManifestContent += 'locale pdf.js ' + locale + ' locale/' +
157+
locale + '/\n';
157158

158159
if (test('-f', path + '/viewer.properties')) {
159160
var properties = cat(path + '/viewer.properties');
@@ -231,9 +232,10 @@ target.bundle = function() {
231232
//
232233
// make pagesrepo
233234
//
234-
// This target clones the gh-pages repo into the build directory. It deletes the current contents
235-
// of the repo, since we overwrite everything with data from the master repo. The 'make web' target
236-
// then uses 'git add -A' to track additions, modifications, moves, and deletions.
235+
// This target clones the gh-pages repo into the build directory. It deletes
236+
// the current contents of the repo, since we overwrite everything with data
237+
// from the master repo. The 'make web' target then uses 'git add -A' to track
238+
// additions, modifications, moves, and deletions.
237239
target.pagesrepo = function() {
238240
cd(ROOT_DIR);
239241
echo();
@@ -264,8 +266,8 @@ target.pagesrepo = function() {
264266
// Extension stuff
265267
//
266268

267-
var EXTENSION_BASE_VERSION = 'f0f0418a9c6637981fe1182b9212c2d592774c7d',
268-
EXTENSION_VERSION_PREFIX = '0.3.',
269+
var EXTENSION_BASE_VERSION = 'fad38f8286acc0a23b10cc95dda800530adaf160',
270+
EXTENSION_VERSION_PREFIX = '0.4.',
269271
EXTENSION_BUILD_NUMBER,
270272
EXTENSION_VERSION;
271273

@@ -342,7 +344,8 @@ target.firefox = function() {
342344
mkdir('-p', FIREFOX_BUILD_CONTENT_DIR + BUILD_DIR);
343345
mkdir('-p', FIREFOX_BUILD_CONTENT_DIR + '/web');
344346

345-
cp(FIREFOX_CONTENT_DIR + 'PdfJs-stub.jsm', FIREFOX_BUILD_CONTENT_DIR + 'PdfJs.jsm');
347+
cp(FIREFOX_CONTENT_DIR + 'PdfJs-stub.jsm',
348+
FIREFOX_BUILD_CONTENT_DIR + 'PdfJs.jsm');
346349

347350
// Copy extension files
348351
cd('extensions/firefox');
@@ -368,29 +371,38 @@ target.firefox = function() {
368371
});
369372

370373
// Update the build version number
371-
sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION, FIREFOX_BUILD_DIR + '/install.rdf');
372-
sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION, FIREFOX_BUILD_DIR + '/update.rdf');
373-
374-
sed('-i', /PDFJSSCRIPT_STREAM_CONVERTER_ID/, FIREFOX_STREAM_CONVERTER_ID, FIREFOX_BUILD_DIR + 'components/PdfStreamConverter.js');
375-
sed('-i', /PDFJSSCRIPT_PREF_PREFIX/, FIREFOX_PREF_PREFIX, FIREFOX_BUILD_DIR + 'components/PdfStreamConverter.js');
376-
sed('-i', /PDFJSSCRIPT_MOZ_CENTRAL/, 'false', FIREFOX_BUILD_DIR + 'components/PdfStreamConverter.js');
374+
sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION,
375+
FIREFOX_BUILD_DIR + '/install.rdf');
376+
sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION,
377+
FIREFOX_BUILD_DIR + '/update.rdf');
378+
379+
sed('-i', /PDFJSSCRIPT_STREAM_CONVERTER_ID/, FIREFOX_STREAM_CONVERTER_ID,
380+
FIREFOX_BUILD_DIR + 'components/PdfStreamConverter.js');
381+
sed('-i', /PDFJSSCRIPT_PREF_PREFIX/, FIREFOX_PREF_PREFIX,
382+
FIREFOX_BUILD_DIR + 'components/PdfStreamConverter.js');
383+
sed('-i', /PDFJSSCRIPT_MOZ_CENTRAL/, 'false',
384+
FIREFOX_BUILD_DIR + 'components/PdfStreamConverter.js');
377385

378386
// Update localized metadata
379387
var localizedMetadata = cat(EXTENSION_SRC_DIR + '/firefox/metadata.inc');
380-
sed('-i', /.*PDFJS_LOCALIZED_METADATA.*\n/, localizedMetadata, FIREFOX_BUILD_DIR + '/install.rdf');
388+
sed('-i', /.*PDFJS_LOCALIZED_METADATA.*\n/, localizedMetadata,
389+
FIREFOX_BUILD_DIR + '/install.rdf');
381390
var chromeManifest = cat(EXTENSION_SRC_DIR + '/firefox/chrome.manifest.inc');
382-
sed('-i', /.*PDFJS_SUPPORTED_LOCALES.*\n/, chromeManifest, FIREFOX_BUILD_DIR + '/chrome.manifest');
391+
sed('-i', /.*PDFJS_SUPPORTED_LOCALES.*\n/, chromeManifest,
392+
FIREFOX_BUILD_DIR + '/chrome.manifest');
383393

384394
// Create the xpi
385395
cd(FIREFOX_BUILD_DIR);
386-
exec('zip -r ' + FIREFOX_EXTENSION_NAME + ' ' + FIREFOX_EXTENSION_FILES.join(' '));
396+
exec('zip -r ' + FIREFOX_EXTENSION_NAME + ' ' +
397+
FIREFOX_EXTENSION_FILES.join(' '));
387398
echo('extension created: ' + FIREFOX_EXTENSION_NAME);
388399
cd(ROOT_DIR);
389400

390401
// Build the amo extension too (remove the updateUrl)
391402
cd(FIREFOX_BUILD_DIR);
392403
sed('-i', /.*updateURL.*\n/, '', 'install.rdf');
393-
exec('zip -r ' + FIREFOX_AMO_EXTENSION_NAME + ' ' + FIREFOX_EXTENSION_FILES.join(' '));
404+
exec('zip -r ' + FIREFOX_AMO_EXTENSION_NAME + ' ' +
405+
FIREFOX_EXTENSION_FILES.join(' '));
394406
echo('AMO extension created: ' + FIREFOX_AMO_EXTENSION_NAME);
395407
cd(ROOT_DIR);
396408
};
@@ -438,13 +450,14 @@ target.mozcentral = function() {
438450
mkdir('-p', MOZCENTRAL_CONTENT_DIR + BUILD_DIR);
439451
mkdir('-p', MOZCENTRAL_CONTENT_DIR + '/web');
440452

441-
cp(FIREFOX_CONTENT_DIR + 'PdfJs.jsm', MOZCENTRAL_CONTENT_DIR)
453+
cp(FIREFOX_CONTENT_DIR + 'PdfJs.jsm', MOZCENTRAL_CONTENT_DIR);
442454

443455
// Copy extension files
444456
cd('extensions/firefox');
445-
cp('-R', FIREFOX_EXTENSION_FILES_TO_COPY, ROOT_DIR + MOZCENTRAL_EXTENSION_DIR);
457+
cp('-R', FIREFOX_EXTENSION_FILES_TO_COPY,
458+
ROOT_DIR + MOZCENTRAL_EXTENSION_DIR);
446459
mv('-f', ROOT_DIR + MOZCENTRAL_EXTENSION_DIR + '/chrome-mozcentral.manifest',
447-
ROOT_DIR + MOZCENTRAL_EXTENSION_DIR + '/chrome.manifest')
460+
ROOT_DIR + MOZCENTRAL_EXTENSION_DIR + '/chrome.manifest');
448461
cd(ROOT_DIR);
449462

450463
var setup = {
@@ -469,18 +482,22 @@ target.mozcentral = function() {
469482
cp(DEFAULT_LOCALE_FILES, MOZCENTRAL_L10N_DIR);
470483

471484
// Update the build version number
472-
sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION, MOZCENTRAL_EXTENSION_DIR + 'README.mozilla');
485+
sed('-i', /PDFJSSCRIPT_VERSION/, EXTENSION_VERSION,
486+
MOZCENTRAL_EXTENSION_DIR + 'README.mozilla');
473487

474-
sed('-i', /PDFJSSCRIPT_STREAM_CONVERTER_ID/, MOZCENTRAL_STREAM_CONVERTER_ID, MOZCENTRAL_EXTENSION_DIR + 'components/PdfStreamConverter.js');
475-
sed('-i', /PDFJSSCRIPT_PREF_PREFIX/, MOZCENTRAL_PREF_PREFIX, MOZCENTRAL_EXTENSION_DIR + 'components/PdfStreamConverter.js');
476-
sed('-i', /PDFJSSCRIPT_MOZ_CENTRAL/, 'true', MOZCENTRAL_EXTENSION_DIR + 'components/PdfStreamConverter.js');
488+
sed('-i', /PDFJSSCRIPT_STREAM_CONVERTER_ID/, MOZCENTRAL_STREAM_CONVERTER_ID,
489+
MOZCENTRAL_EXTENSION_DIR + 'components/PdfStreamConverter.js');
490+
sed('-i', /PDFJSSCRIPT_PREF_PREFIX/, MOZCENTRAL_PREF_PREFIX,
491+
MOZCENTRAL_EXTENSION_DIR + 'components/PdfStreamConverter.js');
492+
sed('-i', /PDFJSSCRIPT_MOZ_CENTRAL/, 'true',
493+
MOZCENTRAL_EXTENSION_DIR + 'components/PdfStreamConverter.js');
477494

478495
// List all files for mozilla-central
479496
cd(MOZCENTRAL_EXTENSION_DIR);
480497
var extensionFiles = '';
481-
find(FIREFOX_MC_EXTENSION_FILES).forEach(function(file){
498+
find(FIREFOX_MC_EXTENSION_FILES).forEach(function(file) {
482499
if (test('-f', file))
483-
extensionFiles += file+'\n';
500+
extensionFiles += file + '\n';
484501
});
485502
extensionFiles.to('extension-files');
486503
cd(ROOT_DIR);
@@ -546,7 +563,8 @@ target.chrome = function() {
546563
defines: defines,
547564
copy: [
548565
[COMMON_WEB_FILES, CHROME_BUILD_CONTENT_DIR + '/web'],
549-
[['extensions/chrome/*.json', 'extensions/chrome/*.html'], CHROME_BUILD_DIR],
566+
[['extensions/chrome/*.json', 'extensions/chrome/*.html'],
567+
CHROME_BUILD_DIR],
550568
[BUILD_TARGET, CHROME_BUILD_CONTENT_DIR + BUILD_TARGET],
551569
['external/webL10n/l10n.js', CHROME_BUILD_CONTENT_DIR + '/web']
552570
],
@@ -592,19 +610,20 @@ target.browsertest = function(options) {
592610
echo('### Running browser tests');
593611

594612
var PDF_TEST = env['PDF_TEST'] || 'test_manifest.json',
595-
PDF_BROWSERS = env['PDF_BROWSERS'] || 'resources/browser_manifests/browser_manifest.json';
613+
PDF_BROWSERS = env['PDF_BROWSERS'] ||
614+
'resources/browser_manifests/browser_manifest.json';
596615

597616
if (!test('-f', 'test/' + PDF_BROWSERS)) {
598617
echo('Browser manifest file test/' + PDF_BROWSERS + ' does not exist.');
599-
echo('Try copying one of the examples in test/resources/browser_manifests/');
618+
echo('Copy one of the examples in test/resources/browser_manifests/');
600619
exit(1);
601620
}
602621

603622
var reftest = (options && options.noreftest) ? '' : '--reftest';
604623

605624
cd('test');
606-
exec(PYTHON_BIN + ' -u test.py '+reftest+' --browserManifestFile=' + PDF_BROWSERS +
607-
' --manifestFile=' + PDF_TEST, {async: true});
625+
exec(PYTHON_BIN + ' -u test.py ' + reftest + ' --browserManifestFile=' +
626+
PDF_BROWSERS + ' --manifestFile=' + PDF_TEST, {async: true});
608627
};
609628

610629
//
@@ -615,17 +634,18 @@ target.unittest = function(options, callback) {
615634
echo();
616635
echo('### Running unit tests');
617636

618-
var PDF_BROWSERS = env['PDF_BROWSERS'] || 'resources/browser_manifests/browser_manifest.json';
637+
var PDF_BROWSERS = env['PDF_BROWSERS'] ||
638+
'resources/browser_manifests/browser_manifest.json';
619639

620640
if (!test('-f', 'test/' + PDF_BROWSERS)) {
621641
echo('Browser manifest file test/' + PDF_BROWSERS + ' does not exist.');
622-
echo('Try copying one of the examples in test/resources/browser_manifests/');
642+
echo('Copy one of the examples in test/resources/browser_manifests/');
623643
exit(1);
624644
}
625645
callback = callback || function() {};
626646
cd('test');
627-
exec(PYTHON_BIN + ' -u test.py --unitTest --browserManifestFile=' + PDF_BROWSERS,
628-
{async: true}, callback);
647+
exec(PYTHON_BIN + ' -u test.py --unitTest --browserManifestFile=' +
648+
PDF_BROWSERS, {async: true}, callback);
629649
};
630650

631651
//
@@ -637,17 +657,18 @@ target.botmakeref = function() {
637657
echo('### Creating reference images');
638658

639659
var PDF_TEST = env['PDF_TEST'] || 'test_manifest.json',
640-
PDF_BROWSERS = env['PDF_BROWSERS'] || 'resources/browser_manifests/browser_manifest.json';
660+
PDF_BROWSERS = env['PDF_BROWSERS'] ||
661+
'resources/browser_manifests/browser_manifest.json';
641662

642663
if (!test('-f', 'test/' + PDF_BROWSERS)) {
643664
echo('Browser manifest file test/' + PDF_BROWSERS + ' does not exist.');
644-
echo('Try copying one of the examples in test/resources/browser_manifests/');
665+
echo('Copy one of the examples in test/resources/browser_manifests/');
645666
exit(1);
646667
}
647668

648669
cd('test');
649-
exec(PYTHON_BIN + ' -u test.py --masterMode --noPrompts --browserManifestFile=' + PDF_BROWSERS,
650-
{async: true});
670+
exec(PYTHON_BIN + ' -u test.py --masterMode --noPrompts ' +
671+
'--browserManifestFile=' + PDF_BROWSERS, {async: true});
651672
};
652673

653674

src/fonts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4100,7 +4100,7 @@ Type1Font.prototype = {
41004100
// charstring changes size - can't cache .length in loop
41014101
for (var i = 0; i < charstring.length; i++) {
41024102
var command = charstring[i];
4103-
if (command.charAt) {
4103+
if (typeof command === 'string') {
41044104
var cmd = map[command];
41054105
assert(cmd, 'Unknow command: ' + command);
41064106

0 commit comments

Comments
 (0)