Merge pull request #2360 from waddlesplash/refactor
Refactor constant names in various files
This commit is contained in:
commit
621e8e1ea9
@ -207,7 +207,7 @@ var CanvasExtraState = (function CanvasExtraStateClosure() {
|
|||||||
var CanvasGraphics = (function CanvasGraphicsClosure() {
|
var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||||
// Defines the time the executeOperatorList is going to be executing
|
// Defines the time the executeOperatorList is going to be executing
|
||||||
// before it stops and shedules a continue of execution.
|
// before it stops and shedules a continue of execution.
|
||||||
var kExecutionTime = 15;
|
var EXECUTION_TIME = 15;
|
||||||
|
|
||||||
function CanvasGraphics(canvasCtx, commonObjs, objs, textLayer) {
|
function CanvasGraphics(canvasCtx, commonObjs, objs, textLayer) {
|
||||||
this.ctx = canvasCtx;
|
this.ctx = canvasCtx;
|
||||||
@ -283,7 +283,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var executionEndIdx;
|
var executionEndIdx;
|
||||||
var endTime = Date.now() + kExecutionTime;
|
var endTime = Date.now() + EXECUTION_TIME;
|
||||||
|
|
||||||
var commonObjs = this.commonObjs;
|
var commonObjs = this.commonObjs;
|
||||||
var objs = this.objs;
|
var objs = this.objs;
|
||||||
|
@ -515,8 +515,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
getTextContent: function PartialEvaluator_getTextContent(
|
getTextContent: function PartialEvaluator_getTextContent(
|
||||||
stream, resources, state) {
|
stream, resources, state) {
|
||||||
var bidiTexts;
|
var bidiTexts;
|
||||||
var kSpaceFactor = 0.35;
|
var SPACE_FACTOR = 0.35;
|
||||||
var kMultipleSpaceFactor = 1.5;
|
var MULTI_SPACE_FACTOR = 1.5;
|
||||||
|
|
||||||
if (!state) {
|
if (!state) {
|
||||||
bidiTexts = [];
|
bidiTexts = [];
|
||||||
@ -559,12 +559,12 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
chunk += fontCharsToUnicode(items[j], font);
|
chunk += fontCharsToUnicode(items[j], font);
|
||||||
} else if (items[j] < 0 && font.spaceWidth > 0) {
|
} else if (items[j] < 0 && font.spaceWidth > 0) {
|
||||||
var fakeSpaces = -items[j] / font.spaceWidth;
|
var fakeSpaces = -items[j] / font.spaceWidth;
|
||||||
if (fakeSpaces > kMultipleSpaceFactor) {
|
if (fakeSpaces > MULTI_SPACE_FACTOR) {
|
||||||
fakeSpaces = Math.round(fakeSpaces);
|
fakeSpaces = Math.round(fakeSpaces);
|
||||||
while (fakeSpaces--) {
|
while (fakeSpaces--) {
|
||||||
chunk += ' ';
|
chunk += ' ';
|
||||||
}
|
}
|
||||||
} else if (fakeSpaces > kSpaceFactor) {
|
} else if (fakeSpaces > SPACE_FACTOR) {
|
||||||
chunk += ' ';
|
chunk += ' ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
66
src/fonts.js
66
src/fonts.js
@ -17,22 +17,17 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/**
|
|
||||||
* Maximum time to wait for a font to be loaded by font-face rules.
|
|
||||||
*/
|
|
||||||
var kMaxWaitForFontFace = 1000;
|
|
||||||
|
|
||||||
// Unicode Private Use Area
|
// Unicode Private Use Area
|
||||||
var kCmapGlyphOffset = 0xE000;
|
var CMAP_GLYPH_OFFSET = 0xE000;
|
||||||
var kSizeOfGlyphArea = 0x1900;
|
var GLYPH_AREA_SIZE = 0x1900;
|
||||||
var kSymbolicFontGlyphOffset = 0xF000;
|
var SYMBOLIC_FONT_GLYPH_OFFSET = 0xF000;
|
||||||
|
|
||||||
// PDF Glyph Space Units are one Thousandth of a TextSpace Unit
|
// PDF Glyph Space Units are one Thousandth of a TextSpace Unit
|
||||||
// except for Type 3 fonts
|
// except for Type 3 fonts
|
||||||
var kPDFGlyphSpaceUnits = 1000;
|
var PDF_GLYPH_SPACE_UNITS = 1000;
|
||||||
|
|
||||||
// Until hinting is fully supported this constant can be used
|
// Until hinting is fully supported this constant can be used
|
||||||
var kHintingEnabled = false;
|
var HINTING_ENABLED = false;
|
||||||
|
|
||||||
var FontFlags = {
|
var FontFlags = {
|
||||||
FixedPitch: 1,
|
FixedPitch: 1,
|
||||||
@ -804,9 +799,9 @@ function isRTLRangeFor(value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isSpecialUnicode(unicode) {
|
function isSpecialUnicode(unicode) {
|
||||||
return (unicode <= 0x1F || (unicode >= 127 && unicode < kSizeOfGlyphArea)) ||
|
return (unicode <= 0x1F || (unicode >= 127 && unicode < GLYPH_AREA_SIZE)) ||
|
||||||
(unicode >= kCmapGlyphOffset &&
|
(unicode >= CMAP_GLYPH_OFFSET &&
|
||||||
unicode < kCmapGlyphOffset + kSizeOfGlyphArea);
|
unicode < CMAP_GLYPH_OFFSET + GLYPH_AREA_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The normalization table is obtained by filtering the Unicode characters
|
// The normalization table is obtained by filtering the Unicode characters
|
||||||
@ -2627,7 +2622,7 @@ var Font = (function FontClosure() {
|
|||||||
lastCharIndex = 255;
|
lastCharIndex = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
var unitsPerEm = override.unitsPerEm || kPDFGlyphSpaceUnits;
|
var unitsPerEm = override.unitsPerEm || PDF_GLYPH_SPACE_UNITS;
|
||||||
var typoAscent = override.ascent || properties.ascent;
|
var typoAscent = override.ascent || properties.ascent;
|
||||||
var typoDescent = override.descent || properties.descent;
|
var typoDescent = override.descent || properties.descent;
|
||||||
var winAscent = override.yMax || typoAscent;
|
var winAscent = override.yMax || typoAscent;
|
||||||
@ -2635,12 +2630,13 @@ var Font = (function FontClosure() {
|
|||||||
|
|
||||||
// if there is a units per em value but no other override
|
// if there is a units per em value but no other override
|
||||||
// then scale the calculated ascent
|
// then scale the calculated ascent
|
||||||
if (unitsPerEm != kPDFGlyphSpaceUnits &&
|
if (unitsPerEm != PDF_GLYPH_SPACE_UNITS &&
|
||||||
'undefined' == typeof(override.ascent)) {
|
'undefined' == typeof(override.ascent)) {
|
||||||
// if the font units differ to the PDF glyph space units
|
// if the font units differ to the PDF glyph space units
|
||||||
// then scale up the values
|
// then scale up the values
|
||||||
typoAscent = Math.round(typoAscent * unitsPerEm / kPDFGlyphSpaceUnits);
|
typoAscent = Math.round(typoAscent * unitsPerEm / PDF_GLYPH_SPACE_UNITS);
|
||||||
typoDescent = Math.round(typoDescent * unitsPerEm / kPDFGlyphSpaceUnits);
|
typoDescent = Math.round(typoDescent * unitsPerEm /
|
||||||
|
PDF_GLYPH_SPACE_UNITS);
|
||||||
winAscent = typoAscent;
|
winAscent = typoAscent;
|
||||||
winDescent = -typoDescent;
|
winDescent = -typoDescent;
|
||||||
}
|
}
|
||||||
@ -3411,13 +3407,13 @@ var Font = (function FontClosure() {
|
|||||||
}
|
}
|
||||||
// trying to fit as many unassigned symbols as we can
|
// trying to fit as many unassigned symbols as we can
|
||||||
// in the range allocated for the user defined symbols
|
// in the range allocated for the user defined symbols
|
||||||
var unusedUnicode = kCmapGlyphOffset;
|
var unusedUnicode = CMAP_GLYPH_OFFSET;
|
||||||
for (var j = 0, jj = unassignedUnicodeItems.length; j < jj; j++) {
|
for (var j = 0, jj = unassignedUnicodeItems.length; j < jj; j++) {
|
||||||
var i = unassignedUnicodeItems[j];
|
var i = unassignedUnicodeItems[j];
|
||||||
var cid = gidToCidMap[i] || i;
|
var cid = gidToCidMap[i] || i;
|
||||||
while (unusedUnicode in usedUnicodes)
|
while (unusedUnicode in usedUnicodes)
|
||||||
unusedUnicode++;
|
unusedUnicode++;
|
||||||
if (unusedUnicode >= kCmapGlyphOffset + kSizeOfGlyphArea)
|
if (unusedUnicode >= CMAP_GLYPH_OFFSET + GLYPH_AREA_SIZE)
|
||||||
break;
|
break;
|
||||||
var unicode = unusedUnicode++;
|
var unicode = unusedUnicode++;
|
||||||
this.toFontChar[cid] = unicode;
|
this.toFontChar[cid] = unicode;
|
||||||
@ -3441,7 +3437,7 @@ var Font = (function FontClosure() {
|
|||||||
ids[i] = i;
|
ids[i] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
var unusedUnicode = kCmapGlyphOffset;
|
var unusedUnicode = CMAP_GLYPH_OFFSET;
|
||||||
var glyphNames = properties.glyphNames || [];
|
var glyphNames = properties.glyphNames || [];
|
||||||
var encoding = properties.baseEncoding;
|
var encoding = properties.baseEncoding;
|
||||||
var differences = properties.differences;
|
var differences = properties.differences;
|
||||||
@ -3522,7 +3518,7 @@ var Font = (function FontClosure() {
|
|||||||
for (var i = 0, ii = glyphs.length; i < ii; i++) {
|
for (var i = 0, ii = glyphs.length; i < ii; i++) {
|
||||||
var code = glyphs[i].unicode;
|
var code = glyphs[i].unicode;
|
||||||
var gid = ids[i];
|
var gid = ids[i];
|
||||||
glyphs[i].unicode += kCmapGlyphOffset;
|
glyphs[i].unicode += CMAP_GLYPH_OFFSET;
|
||||||
toFontChar[code] = glyphs[i].unicode;
|
toFontChar[code] = glyphs[i].unicode;
|
||||||
|
|
||||||
var glyphName = glyphNames[gid] || encoding[code];
|
var glyphName = glyphNames[gid] || encoding[code];
|
||||||
@ -3590,7 +3586,7 @@ var Font = (function FontClosure() {
|
|||||||
if (this.isSymbolicFont) {
|
if (this.isSymbolicFont) {
|
||||||
for (var i = 0, ii = glyphs.length; i < ii; i++) {
|
for (var i = 0, ii = glyphs.length; i < ii; i++) {
|
||||||
var code = glyphs[i].unicode & 0xFF;
|
var code = glyphs[i].unicode & 0xFF;
|
||||||
var fontCharCode = kSymbolicFontGlyphOffset | code;
|
var fontCharCode = SYMBOLIC_FONT_GLYPH_OFFSET | code;
|
||||||
glyphs[i].unicode = toFontChar[code] = fontCharCode;
|
glyphs[i].unicode = toFontChar[code] = fontCharCode;
|
||||||
}
|
}
|
||||||
this.useToFontChar = true;
|
this.useToFontChar = true;
|
||||||
@ -3695,7 +3691,7 @@ var Font = (function FontClosure() {
|
|||||||
// to write the table entry information about a table and another offset
|
// to write the table entry information about a table and another offset
|
||||||
// representing the offset where to draw the actual data of a particular
|
// representing the offset where to draw the actual data of a particular
|
||||||
// table
|
// table
|
||||||
var kRequiredTablesCount = 9;
|
var REQ_TABLES_CNT = 9;
|
||||||
|
|
||||||
var otf = {
|
var otf = {
|
||||||
file: '',
|
file: '',
|
||||||
@ -3827,7 +3823,7 @@ var Font = (function FontClosure() {
|
|||||||
|
|
||||||
buildToFontChar: function Font_buildToFontChar(toUnicode) {
|
buildToFontChar: function Font_buildToFontChar(toUnicode) {
|
||||||
var result = [];
|
var result = [];
|
||||||
var unusedUnicode = kCmapGlyphOffset;
|
var unusedUnicode = CMAP_GLYPH_OFFSET;
|
||||||
for (var i = 0, ii = toUnicode.length; i < ii; i++) {
|
for (var i = 0, ii = toUnicode.length; i < ii; i++) {
|
||||||
var unicode = toUnicode[i];
|
var unicode = toUnicode[i];
|
||||||
var fontCharCode = typeof unicode === 'object' ? unusedUnicode++ :
|
var fontCharCode = typeof unicode === 'object' ? unusedUnicode++ :
|
||||||
@ -4151,8 +4147,8 @@ var Type1Parser = function type1Parser() {
|
|||||||
* of Plaintext Bytes. The function took a key as a parameter which can be
|
* of Plaintext Bytes. The function took a key as a parameter which can be
|
||||||
* for decrypting the eexec block of for decoding charStrings.
|
* for decrypting the eexec block of for decoding charStrings.
|
||||||
*/
|
*/
|
||||||
var kEexecEncryptionKey = 55665;
|
var EEXEC_ENCRYPT_KEY = 55665;
|
||||||
var kCharStringsEncryptionKey = 4330;
|
var CHAR_STRS_ENCRYPT_KEY = 4330;
|
||||||
|
|
||||||
function decrypt(stream, key, discardNumber) {
|
function decrypt(stream, key, discardNumber) {
|
||||||
var r = key, c1 = 52845, c2 = 22719;
|
var r = key, c1 = 52845, c2 = 22719;
|
||||||
@ -4268,7 +4264,7 @@ var Type1Parser = function type1Parser() {
|
|||||||
'31': 'hvcurveto'
|
'31': 'hvcurveto'
|
||||||
};
|
};
|
||||||
|
|
||||||
var kEscapeCommand = 12;
|
var ESCAPE_CMD = 12;
|
||||||
|
|
||||||
// Breaks up the stack by arguments and also calculates the value.
|
// Breaks up the stack by arguments and also calculates the value.
|
||||||
function breakUpArgs(stack, numArgs) {
|
function breakUpArgs(stack, numArgs) {
|
||||||
@ -4320,7 +4316,7 @@ var Type1Parser = function type1Parser() {
|
|||||||
|
|
||||||
if (value < 32) {
|
if (value < 32) {
|
||||||
var command = null;
|
var command = null;
|
||||||
if (value == kEscapeCommand) {
|
if (value == ESCAPE_CMD) {
|
||||||
var escape = array[++i];
|
var escape = array[++i];
|
||||||
|
|
||||||
// TODO Clean this code
|
// TODO Clean this code
|
||||||
@ -4374,7 +4370,7 @@ var Type1Parser = function type1Parser() {
|
|||||||
var args = breakUpArgs(charstring, 5);
|
var args = breakUpArgs(charstring, 5);
|
||||||
var arg0 = args[0];
|
var arg0 = args[0];
|
||||||
charstring.splice(arg0.offset, arg0.arg.length);
|
charstring.splice(arg0.offset, arg0.arg.length);
|
||||||
} else if (!kHintingEnabled && (escape == 1 || escape == 2)) {
|
} else if (!HINTING_ENABLED && (escape == 1 || escape == 2)) {
|
||||||
charstring.push('drop', 'drop', 'drop', 'drop', 'drop', 'drop');
|
charstring.push('drop', 'drop', 'drop', 'drop', 'drop', 'drop');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -4416,7 +4412,7 @@ var Type1Parser = function type1Parser() {
|
|||||||
if (flexState > 1)
|
if (flexState > 1)
|
||||||
continue; // ignoring rmoveto
|
continue; // ignoring rmoveto
|
||||||
value = 5; // first segment replacing with rlineto
|
value = 5; // first segment replacing with rlineto
|
||||||
} else if (!kHintingEnabled && (value == 1 || value == 3)) {
|
} else if (!HINTING_ENABLED && (value == 1 || value == 3)) {
|
||||||
charstring.push('drop', 'drop');
|
charstring.push('drop', 'drop');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -4508,7 +4504,7 @@ var Type1Parser = function type1Parser() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.extractFontProgram = function Type1Parser_extractFontProgram(stream) {
|
this.extractFontProgram = function Type1Parser_extractFontProgram(stream) {
|
||||||
var eexec = decrypt(stream, kEexecEncryptionKey, 4);
|
var eexec = decrypt(stream, EEXEC_ENCRYPT_KEY, 4);
|
||||||
var eexecStr = '';
|
var eexecStr = '';
|
||||||
for (var i = 0, ii = eexec.length; i < ii; i++)
|
for (var i = 0, ii = eexec.length; i < ii; i++)
|
||||||
eexecStr += String.fromCharCode(eexec[i]);
|
eexecStr += String.fromCharCode(eexec[i]);
|
||||||
@ -4548,7 +4544,7 @@ var Type1Parser = function type1Parser() {
|
|||||||
i++;
|
i++;
|
||||||
var data = eexec.slice(i, i + length);
|
var data = eexec.slice(i, i + length);
|
||||||
var lenIV = program.properties.privateData['lenIV'];
|
var lenIV = program.properties.privateData['lenIV'];
|
||||||
var encoded = decrypt(data, kCharStringsEncryptionKey, lenIV);
|
var encoded = decrypt(data, CHAR_STRS_ENCRYPT_KEY, lenIV);
|
||||||
var str = decodeCharString(encoded);
|
var str = decodeCharString(encoded);
|
||||||
|
|
||||||
if (glyphsSection) {
|
if (glyphsSection) {
|
||||||
@ -4588,7 +4584,7 @@ var Type1Parser = function type1Parser() {
|
|||||||
getToken(); // read in 'RD'
|
getToken(); // read in 'RD'
|
||||||
var data = eexec.slice(i + 1, i + 1 + length);
|
var data = eexec.slice(i + 1, i + 1 + length);
|
||||||
var lenIV = program.properties.privateData['lenIV'];
|
var lenIV = program.properties.privateData['lenIV'];
|
||||||
var encoded = decrypt(data, kCharStringsEncryptionKey, lenIV);
|
var encoded = decrypt(data, CHAR_STRS_ENCRYPT_KEY, lenIV);
|
||||||
var str = decodeCharString(encoded);
|
var str = decodeCharString(encoded);
|
||||||
i = i + 1 + length;
|
i = i + 1 + length;
|
||||||
t = getToken(); // read in 'NP'
|
t = getToken(); // read in 'NP'
|
||||||
@ -4864,7 +4860,7 @@ Type1Font.prototype = {
|
|||||||
properties) {
|
properties) {
|
||||||
var charstrings = [];
|
var charstrings = [];
|
||||||
var i, length, glyphName;
|
var i, length, glyphName;
|
||||||
var unusedUnicode = kCmapGlyphOffset;
|
var unusedUnicode = CMAP_GLYPH_OFFSET;
|
||||||
for (i = 0, length = glyphs.length; i < length; i++) {
|
for (i = 0, length = glyphs.length; i < length; i++) {
|
||||||
var item = glyphs[i];
|
var item = glyphs[i];
|
||||||
var glyphName = item.glyph;
|
var glyphName = item.glyph;
|
||||||
@ -5189,7 +5185,7 @@ var CFFFont = (function CFFFontClosure() {
|
|||||||
unicodeUsed[code] = true;
|
unicodeUsed[code] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var nextUnusedUnicode = kCmapGlyphOffset;
|
var nextUnusedUnicode = CMAP_GLYPH_OFFSET;
|
||||||
for (var j = 0, jj = unassignedUnicodeItems.length; j < jj; ++j) {
|
for (var j = 0, jj = unassignedUnicodeItems.length; j < jj; ++j) {
|
||||||
var i = unassignedUnicodeItems[j];
|
var i = unassignedUnicodeItems[j];
|
||||||
// giving unicode value anyway
|
// giving unicode value anyway
|
||||||
|
@ -17,18 +17,19 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var kDefaultURL = 'compressed.tracemonkey-pldi-09.pdf';
|
var DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf';
|
||||||
var kDefaultScale = 'auto';
|
var DEFAULT_SCALE = 'auto';
|
||||||
var kDefaultScaleDelta = 1.1;
|
var DEFAULT_SCALE_DELTA = 1.1;
|
||||||
var kUnknownScale = 0;
|
var UNKNOWN_SCALE = 0;
|
||||||
var kCacheSize = 20;
|
var CACHE_SIZE = 20;
|
||||||
var kCssUnits = 96.0 / 72.0;
|
var CSS_UNITS = 96.0 / 72.0;
|
||||||
var kScrollbarPadding = 40;
|
var SCROLLBAR_PADDING = 40;
|
||||||
var kVerticalPadding = 5;
|
var VERTICAL_PADDING = 5;
|
||||||
var kMinScale = 0.25;
|
var MIN_SCALE = 0.25;
|
||||||
var kMaxScale = 4.0;
|
var MAX_SCALE = 4.0;
|
||||||
var kImageDirectory = './images/';
|
var IMAGE_DIR = './images/';
|
||||||
var kSettingsMemory = 20;
|
var SETTINGS_MEMORY = 20;
|
||||||
|
var ANNOT_MIN_SIZE = 10;
|
||||||
var RenderingStates = {
|
var RenderingStates = {
|
||||||
INITIAL: 0,
|
INITIAL: 0,
|
||||||
RUNNING: 1,
|
RUNNING: 1,
|
||||||
@ -42,8 +43,6 @@ var FindStates = {
|
|||||||
FIND_PENDING: 3
|
FIND_PENDING: 3
|
||||||
};
|
};
|
||||||
|
|
||||||
var ANNOT_MIN_SIZE = 10;
|
|
||||||
|
|
||||||
//#if (FIREFOX || MOZCENTRAL || B2G || GENERIC || CHROME)
|
//#if (FIREFOX || MOZCENTRAL || B2G || GENERIC || CHROME)
|
||||||
//PDFJS.workerSrc = '../build/pdf.js';
|
//PDFJS.workerSrc = '../build/pdf.js';
|
||||||
//#endif
|
//#endif
|
||||||
@ -186,7 +185,7 @@ var Settings = (function SettingsClosure() {
|
|||||||
database = JSON.parse(database);
|
database = JSON.parse(database);
|
||||||
if (!('files' in database))
|
if (!('files' in database))
|
||||||
database.files = [];
|
database.files = [];
|
||||||
if (database.files.length >= kSettingsMemory)
|
if (database.files.length >= SETTINGS_MEMORY)
|
||||||
database.files.shift();
|
database.files.shift();
|
||||||
var index;
|
var index;
|
||||||
for (var i = 0, length = database.files.length; i < length; i++) {
|
for (var i = 0, length = database.files.length; i < length; i++) {
|
||||||
@ -228,7 +227,7 @@ var Settings = (function SettingsClosure() {
|
|||||||
return Settings;
|
return Settings;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
var cache = new Cache(kCacheSize);
|
var cache = new Cache(CACHE_SIZE);
|
||||||
var currentPageNumber = 1;
|
var currentPageNumber = 1;
|
||||||
|
|
||||||
var PDFFindController = {
|
var PDFFindController = {
|
||||||
@ -676,7 +675,7 @@ var PDFFindBar = {
|
|||||||
var PDFView = {
|
var PDFView = {
|
||||||
pages: [],
|
pages: [],
|
||||||
thumbnails: [],
|
thumbnails: [],
|
||||||
currentScale: kUnknownScale,
|
currentScale: UNKNOWN_SCALE,
|
||||||
currentScaleValue: null,
|
currentScaleValue: null,
|
||||||
initialBookmark: document.location.hash.substring(1),
|
initialBookmark: document.location.hash.substring(1),
|
||||||
startedTextExtraction: false,
|
startedTextExtraction: false,
|
||||||
@ -742,7 +741,7 @@ var PDFView = {
|
|||||||
|
|
||||||
var pages = this.pages;
|
var pages = this.pages;
|
||||||
for (var i = 0; i < pages.length; i++)
|
for (var i = 0; i < pages.length; i++)
|
||||||
pages[i].update(val * kCssUnits);
|
pages[i].update(val * CSS_UNITS);
|
||||||
|
|
||||||
if (!noScroll && this.currentScale != val)
|
if (!noScroll && this.currentScale != val)
|
||||||
this.pages[this.page - 1].scrollIntoView();
|
this.pages[this.page - 1].scrollIntoView();
|
||||||
@ -772,10 +771,10 @@ var PDFView = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var pageWidthScale = (container.clientWidth - kScrollbarPadding) /
|
var pageWidthScale = (container.clientWidth - SCROLLBAR_PADDING) /
|
||||||
currentPage.width * currentPage.scale / kCssUnits;
|
currentPage.width * currentPage.scale / CSS_UNITS;
|
||||||
var pageHeightScale = (container.clientHeight - kVerticalPadding) /
|
var pageHeightScale = (container.clientHeight - VERTICAL_PADDING) /
|
||||||
currentPage.height * currentPage.scale / kCssUnits;
|
currentPage.height * currentPage.scale / CSS_UNITS;
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case 'page-actual':
|
case 'page-actual':
|
||||||
scale = 1;
|
scale = 1;
|
||||||
@ -799,14 +798,14 @@ var PDFView = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
zoomIn: function pdfViewZoomIn() {
|
zoomIn: function pdfViewZoomIn() {
|
||||||
var newScale = (this.currentScale * kDefaultScaleDelta).toFixed(2);
|
var newScale = (this.currentScale * DEFAULT_SCALE_DELTA).toFixed(2);
|
||||||
newScale = Math.min(kMaxScale, newScale);
|
newScale = Math.min(MAX_SCALE, newScale);
|
||||||
this.parseScale(newScale, true);
|
this.parseScale(newScale, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
zoomOut: function pdfViewZoomOut() {
|
zoomOut: function pdfViewZoomOut() {
|
||||||
var newScale = (this.currentScale / kDefaultScaleDelta).toFixed(2);
|
var newScale = (this.currentScale / DEFAULT_SCALE_DELTA).toFixed(2);
|
||||||
newScale = Math.max(kMinScale, newScale);
|
newScale = Math.max(MIN_SCALE, newScale);
|
||||||
this.parseScale(newScale, true);
|
this.parseScale(newScale, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1312,10 +1311,10 @@ var PDFView = {
|
|||||||
this.page = 1;
|
this.page = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PDFView.currentScale === kUnknownScale) {
|
if (PDFView.currentScale === UNKNOWN_SCALE) {
|
||||||
// Scale was not initialized: invalid bookmark or scale was not specified.
|
// Scale was not initialized: invalid bookmark or scale was not specified.
|
||||||
// Setting the default one.
|
// Setting the default one.
|
||||||
this.parseScale(kDefaultScale, true);
|
this.parseScale(DEFAULT_SCALE, true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1837,7 +1836,7 @@ var PageView = function pageView(container, pdfPage, id, scale,
|
|||||||
}
|
}
|
||||||
var image = createElementWithStyle('img', item, rect);
|
var image = createElementWithStyle('img', item, rect);
|
||||||
var iconName = item.name;
|
var iconName = item.name;
|
||||||
image.src = kImageDirectory + 'annotation-' +
|
image.src = IMAGE_DIR + 'annotation-' +
|
||||||
iconName.toLowerCase() + '.svg';
|
iconName.toLowerCase() + '.svg';
|
||||||
image.alt = mozL10n.get('text_annotation_type', {type: iconName},
|
image.alt = mozL10n.get('text_annotation_type', {type: iconName},
|
||||||
'[{{type}} Annotation]');
|
'[{{type}} Annotation]');
|
||||||
@ -1941,10 +1940,10 @@ var PageView = function pageView(container, pdfPage, id, scale,
|
|||||||
y = dest[3];
|
y = dest[3];
|
||||||
width = dest[4] - x;
|
width = dest[4] - x;
|
||||||
height = dest[5] - y;
|
height = dest[5] - y;
|
||||||
widthScale = (this.container.clientWidth - kScrollbarPadding) /
|
widthScale = (this.container.clientWidth - SCROLLBAR_PADDING) /
|
||||||
width / kCssUnits;
|
width / CSS_UNITS;
|
||||||
heightScale = (this.container.clientHeight - kScrollbarPadding) /
|
heightScale = (this.container.clientHeight - SCROLLBAR_PADDING) /
|
||||||
height / kCssUnits;
|
height / CSS_UNITS;
|
||||||
scale = Math.min(widthScale, heightScale);
|
scale = Math.min(widthScale, heightScale);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1953,8 +1952,8 @@ var PageView = function pageView(container, pdfPage, id, scale,
|
|||||||
|
|
||||||
if (scale && scale !== PDFView.currentScale)
|
if (scale && scale !== PDFView.currentScale)
|
||||||
PDFView.parseScale(scale, true, true);
|
PDFView.parseScale(scale, true, true);
|
||||||
else if (PDFView.currentScale === kUnknownScale)
|
else if (PDFView.currentScale === UNKNOWN_SCALE)
|
||||||
PDFView.parseScale(kDefaultScale, true, true);
|
PDFView.parseScale(DEFAULT_SCALE, true, true);
|
||||||
|
|
||||||
var boundingRect = [
|
var boundingRect = [
|
||||||
this.viewport.convertToViewportPoint(x, y),
|
this.viewport.convertToViewportPoint(x, y),
|
||||||
@ -2432,9 +2431,9 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv, pageIdx) {
|
|||||||
this.setupRenderLayoutTimer = function textLayerSetupRenderLayoutTimer() {
|
this.setupRenderLayoutTimer = function textLayerSetupRenderLayoutTimer() {
|
||||||
// Schedule renderLayout() if user has been scrolling, otherwise
|
// Schedule renderLayout() if user has been scrolling, otherwise
|
||||||
// run it right away
|
// run it right away
|
||||||
var kRenderDelay = 200; // in ms
|
var RENDER_DELAY = 200; // in ms
|
||||||
var self = this;
|
var self = this;
|
||||||
if (Date.now() - PDFView.lastScroll > kRenderDelay) {
|
if (Date.now() - PDFView.lastScroll > RENDER_DELAY) {
|
||||||
// Render right away
|
// Render right away
|
||||||
this.renderLayer();
|
this.renderLayer();
|
||||||
} else {
|
} else {
|
||||||
@ -2443,7 +2442,7 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv, pageIdx) {
|
|||||||
clearTimeout(this.renderTimer);
|
clearTimeout(this.renderTimer);
|
||||||
this.renderTimer = setTimeout(function() {
|
this.renderTimer = setTimeout(function() {
|
||||||
self.setupRenderLayoutTimer();
|
self.setupRenderLayoutTimer();
|
||||||
}, kRenderDelay);
|
}, RENDER_DELAY);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2693,7 +2692,7 @@ document.addEventListener('DOMContentLoaded', function webViewerLoad(evt) {
|
|||||||
var params = PDFView.parseQueryString(document.location.search.substring(1));
|
var params = PDFView.parseQueryString(document.location.search.substring(1));
|
||||||
|
|
||||||
//#if !(FIREFOX || MOZCENTRAL)
|
//#if !(FIREFOX || MOZCENTRAL)
|
||||||
var file = params.file || kDefaultURL;
|
var file = params.file || DEFAULT_URL;
|
||||||
//#else
|
//#else
|
||||||
//var file = window.location.toString()
|
//var file = window.location.toString()
|
||||||
//#endif
|
//#endif
|
||||||
@ -3105,7 +3104,7 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
case 48: // '0'
|
case 48: // '0'
|
||||||
PDFView.parseScale(kDefaultScale, true);
|
PDFView.parseScale(DEFAULT_SCALE, true);
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user