From ec150294ab6f627ab0a5c02c76987585e76367b7 Mon Sep 17 00:00:00 2001 From: Henri Sivonen Date: Fri, 5 Apr 2019 12:08:41 +0300 Subject: [PATCH 1/2] Bug 1513799 - Remove windows-1252 as a Japanese detection outcome. r=emk. If this removal turns out to be OK, we should be able to make the detector decide more quickly between the remaining options. Differential Revision: https://phabricator.services.mozilla.com/D26283 --- .../universalchardet/src/base/moz.build | 1 - .../src/base/nsLatin1Prober.cpp | 131 ------------------ .../src/base/nsLatin1Prober.h | 33 ----- .../src/base/nsUniversalDetector.cpp | 55 ++------ .../src/base/nsUniversalDetector.h | 4 +- .../tests/bug421271_text.html | 5 - .../tests/bug811363-invalid-2.text | 3 - .../tests/bug811363-invalid-3.text | 2 - .../tests/bug811363-invalid-4.text | 1 - extensions/universalchardet/tests/chrome.ini | 8 -- .../tests/test_bug421271.html | 37 ----- .../tests/test_bug811363-1-2.html | 30 ---- .../tests/test_bug811363-1-3.html | 30 ---- .../tests/test_bug811363-1-4.html | 30 ---- 14 files changed, 16 insertions(+), 354 deletions(-) delete mode 100644 extensions/universalchardet/src/base/nsLatin1Prober.cpp delete mode 100644 extensions/universalchardet/src/base/nsLatin1Prober.h delete mode 100644 extensions/universalchardet/tests/bug421271_text.html delete mode 100644 extensions/universalchardet/tests/bug811363-invalid-2.text delete mode 100644 extensions/universalchardet/tests/bug811363-invalid-3.text delete mode 100644 extensions/universalchardet/tests/bug811363-invalid-4.text delete mode 100644 extensions/universalchardet/tests/test_bug421271.html delete mode 100644 extensions/universalchardet/tests/test_bug811363-1-2.html delete mode 100644 extensions/universalchardet/tests/test_bug811363-1-3.html delete mode 100644 extensions/universalchardet/tests/test_bug811363-1-4.html diff --git a/extensions/universalchardet/src/base/moz.build b/extensions/universalchardet/src/base/moz.build index 442579d4aa9d..c2dfdd344f1b 100644 --- a/extensions/universalchardet/src/base/moz.build +++ b/extensions/universalchardet/src/base/moz.build @@ -11,7 +11,6 @@ UNIFIED_SOURCES += [ 'nsEscCharsetProber.cpp', 'nsEscSM.cpp', 'nsEUCJPProber.cpp', - 'nsLatin1Prober.cpp', 'nsMBCSGroupProber.cpp', 'nsMBCSSM.cpp', 'nsSJISProber.cpp', diff --git a/extensions/universalchardet/src/base/nsLatin1Prober.cpp b/extensions/universalchardet/src/base/nsLatin1Prober.cpp deleted file mode 100644 index 91eb926ae4ab..000000000000 --- a/extensions/universalchardet/src/base/nsLatin1Prober.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsLatin1Prober.h" -#include - -#define UDF 0 // undefined -#define OTH 1 // other -#define ASC 2 // ascii capital letter -#define ASS 3 // ascii small letter -#define ACV 4 // accent capital vowel -#define ACO 5 // accent capital other -#define ASV 6 // accent small vowel -#define ASO 7 // accent small other -#define CLASS_NUM 8 // total classes - -static const unsigned char Latin1_CharToClass[] = { - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // 00 - 07 - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // 08 - 0F - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // 10 - 17 - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // 18 - 1F - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // 20 - 27 - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // 28 - 2F - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // 30 - 37 - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // 38 - 3F - OTH, ASC, ASC, ASC, ASC, ASC, ASC, ASC, // 40 - 47 - ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, // 48 - 4F - ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, // 50 - 57 - ASC, ASC, ASC, OTH, OTH, OTH, OTH, OTH, // 58 - 5F - OTH, ASS, ASS, ASS, ASS, ASS, ASS, ASS, // 60 - 67 - ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, // 68 - 6F - ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, // 70 - 77 - ASS, ASS, ASS, OTH, OTH, OTH, OTH, OTH, // 78 - 7F - OTH, UDF, OTH, ASO, OTH, OTH, OTH, OTH, // 80 - 87 - OTH, OTH, ACO, OTH, ACO, UDF, ACO, UDF, // 88 - 8F - UDF, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // 90 - 97 - OTH, OTH, ASO, OTH, ASO, UDF, ASO, ACO, // 98 - 9F - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // A0 - A7 - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // A8 - AF - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // B0 - B7 - OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, // B8 - BF - ACV, ACV, ACV, ACV, ACV, ACV, ACO, ACO, // C0 - C7 - ACV, ACV, ACV, ACV, ACV, ACV, ACV, ACV, // C8 - CF - ACO, ACO, ACV, ACV, ACV, ACV, ACV, OTH, // D0 - D7 - ACV, ACV, ACV, ACV, ACV, ACO, ACO, ACO, // D8 - DF - ASV, ASV, ASV, ASV, ASV, ASV, ASO, ASO, // E0 - E7 - ASV, ASV, ASV, ASV, ASV, ASV, ASV, ASV, // E8 - EF - ASO, ASO, ASV, ASV, ASV, ASV, ASV, OTH, // F0 - F7 - ASV, ASV, ASV, ASV, ASV, ASO, ASO, ASO, // F8 - FF -}; - -/* 0 : illegal - 1 : very unlikely - 2 : normal - 3 : very likely -*/ -static const unsigned char Latin1ClassModel[] = { - /* UDF OTH ASC ASS ACV ACO ASV ASO */ - /*UDF*/ 0, 0, 0, 0, 0, 0, 0, 0, - /*OTH*/ 0, 3, 3, 3, 3, 3, 3, 3, - /*ASC*/ 0, 3, 3, 3, 3, 3, 3, 3, - /*ASS*/ 0, 3, 3, 3, 1, 1, 3, 3, - /*ACV*/ 0, 3, 3, 3, 1, 2, 1, 2, - /*ACO*/ 0, 3, 3, 3, 3, 3, 3, 3, - /*ASV*/ 0, 3, 1, 3, 1, 1, 1, 3, - /*ASO*/ 0, 3, 1, 3, 1, 1, 3, 3, -}; - -void nsLatin1Prober::Reset(void) { - mState = eDetecting; - mLastCharClass = OTH; - for (int i = 0; i < FREQ_CAT_NUM; i++) mFreqCounter[i] = 0; -} - -nsProbingState nsLatin1Prober::HandleData(const char* aBuf, uint32_t aLen) { - char* newBuf1 = 0; - uint32_t newLen1 = 0; - - if (!FilterWithEnglishLetters(aBuf, aLen, &newBuf1, newLen1)) { - newBuf1 = (char*)aBuf; - newLen1 = aLen; - } - - unsigned char charClass; - unsigned char freq; - for (uint32_t i = 0; i < newLen1; i++) { - charClass = Latin1_CharToClass[(unsigned char)newBuf1[i]]; - freq = Latin1ClassModel[mLastCharClass * CLASS_NUM + charClass]; - if (freq == 0) { - mState = eNotMe; - break; - } - mFreqCounter[freq]++; - mLastCharClass = charClass; - } - - if (newBuf1 != aBuf) free(newBuf1); - - return mState; -} - -float nsLatin1Prober::GetConfidence(void) { - if (mState == eNotMe) return 0.01f; - - float confidence; - uint32_t total = 0; - for (int32_t i = 0; i < FREQ_CAT_NUM; i++) total += mFreqCounter[i]; - - if (!total) - confidence = 0.0f; - else { - confidence = mFreqCounter[3] * 1.0f / total; - confidence -= mFreqCounter[1] * 20.0f / total; - } - - if (confidence < 0.0f) confidence = 0.0f; - - // lower the confidence of latin1 so that other more accurate detector - // can take priority. - confidence *= 0.50f; - - return confidence; -} - -#ifdef DEBUG_chardet -void nsLatin1Prober::DumpStatus() { - printf(" Latin1Prober: %1.3f [%s]\r\n", GetConfidence(), GetCharSetName()); -} -#endif diff --git a/extensions/universalchardet/src/base/nsLatin1Prober.h b/extensions/universalchardet/src/base/nsLatin1Prober.h deleted file mode 100644 index 5c890e2a535d..000000000000 --- a/extensions/universalchardet/src/base/nsLatin1Prober.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsLatin1Prober_h__ -#define nsLatin1Prober_h__ - -#include "nsCharSetProber.h" - -#define FREQ_CAT_NUM 4 - -class nsLatin1Prober : public nsCharSetProber { - public: - nsLatin1Prober(void) { Reset(); } - virtual ~nsLatin1Prober(void) {} - nsProbingState HandleData(const char* aBuf, uint32_t aLen) override; - const char* GetCharSetName() override { return "windows-1252"; } - nsProbingState GetState(void) override { return mState; } - void Reset(void) override; - float GetConfidence(void) override; - -#ifdef DEBUG_chardet - virtual void DumpStatus(); -#endif - - protected: - nsProbingState mState; - char mLastCharClass; - uint32_t mFreqCounter[FREQ_CAT_NUM]; -}; - -#endif /* nsLatin1Prober_h__ */ diff --git a/extensions/universalchardet/src/base/nsUniversalDetector.cpp b/extensions/universalchardet/src/base/nsUniversalDetector.cpp index 4cd8894bbec5..9ff46fa1dff2 100644 --- a/extensions/universalchardet/src/base/nsUniversalDetector.cpp +++ b/extensions/universalchardet/src/base/nsUniversalDetector.cpp @@ -9,12 +9,12 @@ #include "nsMBCSGroupProber.h" #include "nsEscCharsetProber.h" -#include "nsLatin1Prober.h" nsUniversalDetector::nsUniversalDetector() { mDone = false; mBestGuess = -1; // illegal value as signal mInTag = false; + mMultibyteProber = nullptr; mEscCharSetProber = nullptr; mStart = true; @@ -22,15 +22,10 @@ nsUniversalDetector::nsUniversalDetector() { mGotData = false; mInputState = ePureAscii; mLastChar = '\0'; - - uint32_t i; - for (i = 0; i < NUM_OF_CHARSET_PROBERS; i++) mCharSetProbers[i] = nullptr; } nsUniversalDetector::~nsUniversalDetector() { - for (int32_t i = 0; i < NUM_OF_CHARSET_PROBERS; i++) - delete mCharSetProbers[i]; - + delete mMultibyteProber; delete mEscCharSetProber; } @@ -45,11 +40,13 @@ void nsUniversalDetector::Reset() { mInputState = ePureAscii; mLastChar = '\0'; - if (mEscCharSetProber) mEscCharSetProber->Reset(); + if (mMultibyteProber) { + mMultibyteProber->Reset(); + } - uint32_t i; - for (i = 0; i < NUM_OF_CHARSET_PROBERS; i++) - if (mCharSetProbers[i]) mCharSetProbers[i]->Reset(); + if (mEscCharSetProber) { + mEscCharSetProber->Reset(); + } } //--------------------------------------------------------------------- @@ -110,14 +107,9 @@ nsresult nsUniversalDetector::HandleData(const char* aBuf, uint32_t aLen) { mEscCharSetProber = nullptr; } - // start multibyte and singlebyte charset prober - if (nullptr == mCharSetProbers[0]) { - mCharSetProbers[0] = new nsMBCSGroupProber(); - if (nullptr == mCharSetProbers[0]) return NS_ERROR_OUT_OF_MEMORY; - } - if (nullptr == mCharSetProbers[2]) { - mCharSetProbers[2] = new nsLatin1Prober; - if (nullptr == mCharSetProbers[2]) return NS_ERROR_OUT_OF_MEMORY; + // start multibyte charset prober + if (!mMultibyteProber) { + mMultibyteProber = new nsMBCSGroupProber(); } } } else { @@ -144,16 +136,12 @@ nsresult nsUniversalDetector::HandleData(const char* aBuf, uint32_t aLen) { } break; case eHighbyte: - for (i = 0; i < NUM_OF_CHARSET_PROBERS; i++) { - if (mCharSetProbers[i]) { - st = mCharSetProbers[i]->HandleData(aBuf, aLen); + st = mMultibyteProber->HandleData(aBuf, aLen); if (st == eFoundIt) { mDone = true; - mDetectedCharset = mCharSetProbers[i]->GetCharSetName(); + mDetectedCharset = mMultibyteProber->GetCharSetName(); return NS_OK; } - } - } break; default: // pure ascii @@ -179,23 +167,10 @@ void nsUniversalDetector::DataEnd() { switch (mInputState) { case eHighbyte: { - float proberConfidence; - float maxProberConfidence = (float)0.0; - int32_t maxProber = 0; - - for (int32_t i = 0; i < NUM_OF_CHARSET_PROBERS; i++) { - if (mCharSetProbers[i]) { - proberConfidence = mCharSetProbers[i]->GetConfidence(); - if (proberConfidence > maxProberConfidence) { - maxProberConfidence = proberConfidence; - maxProber = i; - } - } - } // do not report anything because we are not confident of it, that's in // fact a negative answer - if (maxProberConfidence > MINIMUM_THRESHOLD) - Report(mCharSetProbers[maxProber]->GetCharSetName()); + if (mMultibyteProber->GetConfidence() > MINIMUM_THRESHOLD) + Report(mMultibyteProber->GetCharSetName()); } break; case eEscAscii: break; diff --git a/extensions/universalchardet/src/base/nsUniversalDetector.h b/extensions/universalchardet/src/base/nsUniversalDetector.h index 16a0d358e721..d16feff2912f 100644 --- a/extensions/universalchardet/src/base/nsUniversalDetector.h +++ b/extensions/universalchardet/src/base/nsUniversalDetector.h @@ -8,8 +8,6 @@ class nsCharSetProber; -#define NUM_OF_CHARSET_PROBERS 3 - typedef enum { ePureAscii = 0, eEscAscii = 1, eHighbyte = 2 } nsInputState; class nsUniversalDetector { @@ -32,7 +30,7 @@ class nsUniversalDetector { int32_t mBestGuess; uint32_t mLanguageFilter; - nsCharSetProber* mCharSetProbers[NUM_OF_CHARSET_PROBERS]; + nsCharSetProber* mMultibyteProber; nsCharSetProber* mEscCharSetProber; }; diff --git a/extensions/universalchardet/tests/bug421271_text.html b/extensions/universalchardet/tests/bug421271_text.html deleted file mode 100644 index dfffc33634a4..000000000000 --- a/extensions/universalchardet/tests/bug421271_text.html +++ /dev/null @@ -1,5 +0,0 @@ - - -BBC - 606 - A Forum Conversation - -

posted 5 Weeks Ago

if rangers draw and marseille and benfica win i stand to lift £825. not bad for a £2 bet.
50p on 3 homes
Man Utd/Marseille/Benfica
50p on 3 Draws
Rangers/Halifax/Bristol City
50p on 3 Aways
Doncaster/Stranraer/Rushden & Diamonds
and 50p on all nine results.
GET IN THERE.

\ No newline at end of file diff --git a/extensions/universalchardet/tests/bug811363-invalid-2.text b/extensions/universalchardet/tests/bug811363-invalid-2.text deleted file mode 100644 index d38980fadc23..000000000000 --- a/extensions/universalchardet/tests/bug811363-invalid-2.text +++ /dev/null @@ -1,3 +0,0 @@ -First bytes of 2-byte sequences (0xc0-0xdf), each followed by a space character: À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß -First bytes of 3-byte sequences (0xe0-0xef), each followed by a space character: à á â ã ä å æ ç è é ê ë ì í î ï -First bytes of 4-byte sequences (0xf0-0xf4), each followed by a space character: ð ñ ò ó ô diff --git a/extensions/universalchardet/tests/bug811363-invalid-3.text b/extensions/universalchardet/tests/bug811363-invalid-3.text deleted file mode 100644 index 1c438d70a005..000000000000 --- a/extensions/universalchardet/tests/bug811363-invalid-3.text +++ /dev/null @@ -1,2 +0,0 @@ -3-byte sequence with last byte missing (U+0000): à° -4-byte sequence with last b0te missing (U+0000): ð°€ diff --git a/extensions/universalchardet/tests/bug811363-invalid-4.text b/extensions/universalchardet/tests/bug811363-invalid-4.text deleted file mode 100644 index 8a943dca3632..000000000000 --- a/extensions/universalchardet/tests/bug811363-invalid-4.text +++ /dev/null @@ -1 +0,0 @@ -Overlong encodings: À¯ à€¯ ð€€¯ diff --git a/extensions/universalchardet/tests/chrome.ini b/extensions/universalchardet/tests/chrome.ini index a067b279e40e..a2b17a4dcebe 100644 --- a/extensions/universalchardet/tests/chrome.ini +++ b/extensions/universalchardet/tests/chrome.ini @@ -2,7 +2,6 @@ support-files = CharsetDetectionTests.js bug306272_text.html - bug421271_text.html bug426271_text-euc-jp.html bug426271_text-utf-8.html bug431054_text.html @@ -19,9 +18,6 @@ support-files = bug811363-8.text bug811363-9.text bug811363-invalid-1.text - bug811363-invalid-2.text - bug811363-invalid-3.text - bug811363-invalid-4.text bug811363-invalid-5.text bug1071816-1_text.html bug1071816-2_text.html @@ -29,7 +25,6 @@ support-files = bug1071816-4_text.html [test_bug306272.html] -[test_bug421271.html] [test_bug426271-euc-jp.html] [test_bug426271-utf-8.html] [test_bug431054-japanese.html] @@ -38,9 +33,6 @@ support-files = [test_bug631751le.html] [test_bug638318.html] [test_bug811363-1-1.html] -[test_bug811363-1-2.html] -[test_bug811363-1-3.html] -[test_bug811363-1-4.html] [test_bug811363-1-5.html] [test_bug811363-2-1.html] [test_bug811363-2-2.html] diff --git a/extensions/universalchardet/tests/test_bug421271.html b/extensions/universalchardet/tests/test_bug421271.html deleted file mode 100644 index 2e6cd29e7a71..000000000000 --- a/extensions/universalchardet/tests/test_bug421271.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - Test for Bug 421271 - - - - - -Mozilla Bug 421271 -

- - -
-
-
- - - diff --git a/extensions/universalchardet/tests/test_bug811363-1-2.html b/extensions/universalchardet/tests/test_bug811363-1-2.html deleted file mode 100644 index 86d00828d432..000000000000 --- a/extensions/universalchardet/tests/test_bug811363-1-2.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - Test for Bug 811363 - - - - - -Mozilla Bug 811363 -

- - -
-
-
- - diff --git a/extensions/universalchardet/tests/test_bug811363-1-3.html b/extensions/universalchardet/tests/test_bug811363-1-3.html deleted file mode 100644 index 782fba27463e..000000000000 --- a/extensions/universalchardet/tests/test_bug811363-1-3.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - Test for Bug 811363 - - - - - -Mozilla Bug 811363 -

- - -
-
-
- - diff --git a/extensions/universalchardet/tests/test_bug811363-1-4.html b/extensions/universalchardet/tests/test_bug811363-1-4.html deleted file mode 100644 index 590f221b147a..000000000000 --- a/extensions/universalchardet/tests/test_bug811363-1-4.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - Test for Bug 811363 - - - - - -Mozilla Bug 811363 -

- - -
-
-
- - From f880e3efcaa0e924349dd0ee0cdc7214d5ba76ad Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Mon, 8 Apr 2019 08:51:19 -0400 Subject: [PATCH 2/2] Bug 1542737 - Update pdf.js to version 2.2.129. r=bdahl --- browser/extensions/pdfjs/README.mozilla | 4 +- browser/extensions/pdfjs/content/build/pdf.js | 48 ++++++++++++++----- .../pdfjs/content/build/pdf.worker.js | 28 +++++++++-- .../extensions/pdfjs/content/web/viewer.js | 26 +++++++++- browser/extensions/pdfjs/moz.yaml | 2 +- 5 files changed, 88 insertions(+), 20 deletions(-) diff --git a/browser/extensions/pdfjs/README.mozilla b/browser/extensions/pdfjs/README.mozilla index f9b9c10b11bd..f2e596d2a094 100644 --- a/browser/extensions/pdfjs/README.mozilla +++ b/browser/extensions/pdfjs/README.mozilla @@ -1,5 +1,5 @@ This is the PDF.js project output, https://github.com/mozilla/pdf.js -Current extension version is: 2.2.117 +Current extension version is: 2.2.129 -Taken from upstream commit: 57abddc9 +Taken from upstream commit: 725a6959 diff --git a/browser/extensions/pdfjs/content/build/pdf.js b/browser/extensions/pdfjs/content/build/pdf.js index 95ec071bc733..7e08f5b03e7e 100644 --- a/browser/extensions/pdfjs/content/build/pdf.js +++ b/browser/extensions/pdfjs/content/build/pdf.js @@ -123,8 +123,8 @@ return /******/ (function(modules) { // webpackBootstrap "use strict"; -var pdfjsVersion = '2.2.117'; -var pdfjsBuild = '57abddc9'; +var pdfjsVersion = '2.2.129'; +var pdfjsBuild = '725a6959'; var pdfjsSharedUtil = __w_pdfjs_require__(1); @@ -1303,7 +1303,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { return worker.messageHandler.sendWithPromise('GetDocRequest', { docId, - apiVersion: '2.2.117', + apiVersion: '2.2.129', source: { data: source.data, url: source.url, @@ -1406,10 +1406,10 @@ class PDFDataRangeTransport { } } - onDataProgress(loaded) { + onDataProgress(loaded, total) { this._readyCapability.promise.then(() => { for (const listener of this._progressListeners) { - listener(loaded); + listener(loaded, total); } }); } @@ -1478,6 +1478,10 @@ class PDFDocumentProxy { return this._transport.getPageLabels(); } + getPageLayout() { + return this._transport.getPageLayout(); + } + getPageMode() { return this._transport.getPageMode(); } @@ -2761,6 +2765,10 @@ class WorkerTransport { return this.messageHandler.sendWithPromise('GetPageLabels', null); } + getPageLayout() { + return this.messageHandler.sendWithPromise('GetPageLayout', null); + } + getPageMode() { return this.messageHandler.sendWithPromise('GetPageMode', null); } @@ -3075,9 +3083,9 @@ const InternalRenderTask = function InternalRenderTaskClosure() { return InternalRenderTask; }(); -const version = '2.2.117'; +const version = '2.2.129'; exports.version = version; -const build = '57abddc9'; +const build = '725a6959'; exports.build = build; /***/ }), @@ -4591,8 +4599,11 @@ var CanvasGraphics = function CanvasGraphicsClosure() { ctx.lineDashOffset = dashPhase; } }, - setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {}, - setFlatness: function CanvasGraphics_setFlatness(flatness) {}, + + setRenderingIntent(intent) {}, + + setFlatness(flatness) {}, + setGState: function CanvasGraphics_setGState(states) { for (var i = 0, ii = states.length; i < ii; i++) { var state = states[i]; @@ -7337,9 +7348,10 @@ var PDFDataTransportStream = function PDFDataTransportStreamClosure() { }); }); - this._pdfDataRangeTransport.addProgressListener(loaded => { + this._pdfDataRangeTransport.addProgressListener((loaded, total) => { this._onProgress({ - loaded + loaded, + total }); }); @@ -7381,15 +7393,25 @@ var PDFDataTransportStream = function PDFDataTransportStreamClosure() { } }, _onProgress: function PDFDataTransportStream_onDataProgress(evt) { - if (this._rangeReaders.length > 0) { + if (evt.total === undefined && this._rangeReaders.length > 0) { var firstReader = this._rangeReaders[0]; if (firstReader.onProgress) { firstReader.onProgress({ loaded: evt.loaded }); + return; } } + + let fullReader = this._fullRequestReader; + + if (fullReader && fullReader.onProgress) { + fullReader.onProgress({ + loaded: evt.loaded, + total: evt.total + }); + } }, _onProgressiveDone() { @@ -9730,7 +9752,7 @@ var _is_node = _interopRequireDefault(__w_pdfjs_require__(21)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -var SVGGraphics = function () { +let SVGGraphics = function () { throw new Error('Not implemented: SVGGraphics'); }; diff --git a/browser/extensions/pdfjs/content/build/pdf.worker.js b/browser/extensions/pdfjs/content/build/pdf.worker.js index 7268779243d0..0859d18039ea 100644 --- a/browser/extensions/pdfjs/content/build/pdf.worker.js +++ b/browser/extensions/pdfjs/content/build/pdf.worker.js @@ -123,8 +123,8 @@ return /******/ (function(modules) { // webpackBootstrap "use strict"; -const pdfjsVersion = '2.2.117'; -const pdfjsBuild = '57abddc9'; +const pdfjsVersion = '2.2.129'; +const pdfjsBuild = '725a6959'; const pdfjsCoreWorker = __w_pdfjs_require__(1); @@ -378,7 +378,7 @@ var WorkerMessageHandler = { var WorkerTasks = []; const verbosity = (0, _util.getVerbosityLevel)(); let apiVersion = docParams.apiVersion; - let workerVersion = '2.2.117'; + let workerVersion = '2.2.129'; if (apiVersion !== workerVersion) { throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`); @@ -644,6 +644,9 @@ var WorkerMessageHandler = { handler.on('GetPageLabels', function wphSetupGetPageLabels(data) { return pdfManager.ensureCatalog('pageLabels'); }); + handler.on('GetPageLayout', function wphSetupGetPageLayout(data) { + return pdfManager.ensureCatalog('pageLayout'); + }); handler.on('GetPageMode', function wphSetupGetPageMode(data) { return pdfManager.ensureCatalog('pageMode'); }); @@ -3747,6 +3750,25 @@ class Catalog { return pageLabels; } + get pageLayout() { + const obj = this.catDict.get('PageLayout'); + let pageLayout = ''; + + if ((0, _primitives.isName)(obj)) { + switch (obj.name) { + case 'SinglePage': + case 'OneColumn': + case 'TwoColumnLeft': + case 'TwoColumnRight': + case 'TwoPageLeft': + case 'TwoPageRight': + pageLayout = obj.name; + } + } + + return (0, _util.shadow)(this, 'pageLayout', pageLayout); + } + get pageMode() { const obj = this.catDict.get('PageMode'); let pageMode = 'UseNone'; diff --git a/browser/extensions/pdfjs/content/web/viewer.js b/browser/extensions/pdfjs/content/web/viewer.js index 31000c880eff..65627260c834 100644 --- a/browser/extensions/pdfjs/content/web/viewer.js +++ b/browser/extensions/pdfjs/content/web/viewer.js @@ -1017,6 +1017,7 @@ let PDFViewerApplication = { }); }); }); + const pageLayoutPromise = pdfDocument.getPageLayout().catch(function () {}); const pageModePromise = pdfDocument.getPageMode().catch(function () {}); const openActionDestPromise = pdfDocument.getOpenActionDestination().catch(function () {}); this.toolbar.setPagesCount(pdfDocument.numPages, false); @@ -1045,7 +1046,7 @@ let PDFViewerApplication = { scrollMode: _ui_utils.ScrollMode.UNKNOWN, spreadMode: _ui_utils.SpreadMode.UNKNOWN }).catch(() => {}); - Promise.all([storePromise, pageModePromise, openActionDestPromise]).then(async ([values = {}, pageMode, openActionDest]) => { + Promise.all([storePromise, pageLayoutPromise, pageModePromise, openActionDestPromise]).then(async ([values = {}, pageLayout, pageMode, openActionDest]) => { const viewOnLoad = _app_options.AppOptions.get('viewOnLoad'); this._initializePdfHistory({ @@ -1088,6 +1089,10 @@ let PDFViewerApplication = { sidebarView = apiPageModeToSidebarView(pageMode); } + if (pageLayout && spreadMode === _ui_utils.SpreadMode.UNKNOWN) { + spreadMode = apiPageLayoutToSpreadMode(pageLayout); + } + this.setInitialView(hash, { rotation, sidebarView, @@ -2340,6 +2345,24 @@ function webViewerKeyDown(evt) { } } +function apiPageLayoutToSpreadMode(layout) { + switch (layout) { + case 'SinglePage': + case 'OneColumn': + return _ui_utils.SpreadMode.NONE; + + case 'TwoColumnLeft': + case 'TwoPageLeft': + return _ui_utils.SpreadMode.ODD; + + case 'TwoColumnRight': + case 'TwoPageRight': + return _ui_utils.SpreadMode.EVEN; + } + + return _ui_utils.SpreadMode.NONE; +} + function apiPageModeToSidebarView(mode) { switch (mode) { case 'UseNone': @@ -11405,6 +11428,7 @@ _app.PDFViewerApplication.externalServices = { case 'progressiveRead': pdfDataRangeTransport.onDataProgressiveRead(args.chunk); + pdfDataRangeTransport.onDataProgress(args.loaded, args.total); break; case 'progressiveDone': diff --git a/browser/extensions/pdfjs/moz.yaml b/browser/extensions/pdfjs/moz.yaml index 1856197c301a..2a4f320368b3 100644 --- a/browser/extensions/pdfjs/moz.yaml +++ b/browser/extensions/pdfjs/moz.yaml @@ -20,7 +20,7 @@ origin: # Human-readable identifier for this version/release # Generally "version NNN", "tag SSS", "bookmark SSS" - release: version 2.2.117 + release: version 2.2.129 # The package's license, where possible using the mnemonic from # https://spdx.org/licenses/