Skip to content

Commit

Permalink
Merge pull request mozilla#676 from vingtetun/oncontextmenu
Browse files Browse the repository at this point in the history
Fix issue 581 by adding oncontextmenu='return false;' to buttons
  • Loading branch information
notmasteryet committed Oct 18, 2011
2 parents d42ee96 + f1444d6 commit 7323e67
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 17 deletions.
14 changes: 11 additions & 3 deletions fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,13 @@ var Font = (function Font() {
};

function createOS2Table(properties, override) {
var override = override || {};
override = override || {
unitsPerEm: 0,
yMax: 0,
yMin: 0,
ascent: 0,
descent: 0
};

var ulUnicodeRange1 = 0;
var ulUnicodeRange2 = 0;
Expand Down Expand Up @@ -1322,7 +1328,8 @@ var Font = (function Font() {
'OS/2': stringToArray(createOS2Table(properties)),

// Character to glyphs mapping
'cmap': createCMapTable(charstrings.slice(), font.glyphIds),
'cmap': createCMapTable(charstrings.slice(),
('glyphIds' in font) ? font.glyphIds: null),

// Font header
'head': (function fontFieldsHead() {
Expand Down Expand Up @@ -2612,7 +2619,8 @@ var Type2CFF = (function type2CFF() {
if (unicode <= 0x1f || (unicode >= 127 && unicode <= 255))
unicode += kCmapGlyphOffset;

var width = isNum(mapping.width) ? mapping.width : defaultWidth;
var width = ('width' in mapping) && isNum(mapping.width) ? mapping.width
: defaultWidth;
properties.encoding[code] = {
unicode: unicode,
width: width
Expand Down
12 changes: 8 additions & 4 deletions pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -5136,7 +5136,8 @@ var CanvasGraphics = (function canvasGraphics() {
stroke: function canvasGraphicsStroke() {
var ctx = this.ctx;
var strokeColor = this.current.strokeColor;
if (strokeColor && strokeColor.type === 'Pattern') {
if (strokeColor && strokeColor.hasOwnProperty('type') &&
strokeColor.type === 'Pattern') {
// for patterns, we transform to pattern space, calculate
// the pattern, call stroke, and restore to user space
ctx.save();
Expand All @@ -5157,7 +5158,8 @@ var CanvasGraphics = (function canvasGraphics() {
var ctx = this.ctx;
var fillColor = this.current.fillColor;

if (fillColor && fillColor.type === 'Pattern') {
if (fillColor && fillColor.hasOwnProperty('type') &&
fillColor.type === 'Pattern') {
ctx.save();
ctx.fillStyle = fillColor.getPattern(ctx);
ctx.fill();
Expand All @@ -5177,7 +5179,8 @@ var CanvasGraphics = (function canvasGraphics() {
var ctx = this.ctx;

var fillColor = this.current.fillColor;
if (fillColor && fillColor.type === 'Pattern') {
if (fillColor && fillColor.hasOwnProperty('type') &&
fillColor.type === 'Pattern') {
ctx.save();
ctx.fillStyle = fillColor.getPattern(ctx);
ctx.fill();
Expand All @@ -5187,7 +5190,8 @@ var CanvasGraphics = (function canvasGraphics() {
}

var strokeColor = this.current.strokeColor;
if (strokeColor && strokeColor.type === 'Pattern') {
if (strokeColor && strokeColor.hasOwnProperty('type') &&
strokeColor.type === 'Pattern') {
ctx.save();
ctx.strokeStyle = strokeColor.getPattern(ctx);
ctx.stroke();
Expand Down
2 changes: 1 addition & 1 deletion web/compatibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@

// IE9 text/html data URI
(function checkDocumentDocumentModeCompatibility() {
if (document.documentMode !== 9)
if (!('documentMode' in document) || document.documentMode !== 9)
return;
// overriding the src property
var originalSrcDescriptor = Object.getOwnPropertyDescriptor(
Expand Down
14 changes: 7 additions & 7 deletions web/viewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

<body>
<div id="controls">
<button id="previous" onclick="PDFView.page--;">
<button id="previous" onclick="PDFView.page--;" oncontextmenu="return false;">
<img src="images/go-up.svg" align="top" height="32"/>
Previous
</button>

<button id="next" onclick="PDFView.page++;">
<button id="next" onclick="PDFView.page++;" oncontextmenu="return false;">
<img src="images/go-down.svg" align="top" height="32"/>
Next
</button>
Expand All @@ -36,16 +36,16 @@

<div class="separator"></div>

<button id="next" title="Zoom Out" onclick="PDFView.zoomOut();">
<button id="zoomOut" title="Zoom Out" onclick="PDFView.zoomOut();" oncontextmenu="return false;">
<img src="images/zoom-out.svg" align="top" height="32"/>
</button>
<button id="next" title="Zoom In" onclick="PDFView.zoomIn();">
<button id="zoomIn" title="Zoom In" onclick="PDFView.zoomIn();" oncontextmenu="return false;">
<img src="images/zoom-in.svg" align="top" height="32"/>
</button>

<div class="separator"></div>

<select id="scaleSelect" onchange="PDFView.parseScale(this.value);">
<select id="scaleSelect" onchange="PDFView.parseScale(this.value);" oncontextmenu="return false;">
<option id="customScaleOption" value="custom"></option>
<option value="0.5">50%</option>
<option value="0.75">75%</option>
Expand All @@ -59,14 +59,14 @@

<div class="separator"></div>

<button id="print" onclick="window.print();">
<button id="print" onclick="window.print();" oncontextmenu="return false;">
<img src="images/document-print.svg" align="top" height="32"/>
Print
</button>

<div class="separator"></div>

<input id="fileInput" type="file"/>
<input id="fileInput" type="file" oncontextmenu="return false;"/>

<div class="separator"></div>

Expand Down
7 changes: 5 additions & 2 deletions web/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ var PDFView = {

while (sidebar.hasChildNodes())
sidebar.removeChild(sidebar.lastChild);
clearInterval(sidebar._loadingInterval);

if ('_loadingInterval' in sidebar)
clearInterval(sidebar._loadingInterval);

var container = document.getElementById('viewer');
while (container.hasChildNodes())
Expand Down Expand Up @@ -544,7 +546,8 @@ window.addEventListener('load', function webViewerLoad(evt) {
params[unescape(param[0])] = unescape(param[1]);
}

PDFView.open(params.file || kDefaultURL, parseFloat(params.scale));
var scale = ('scale' in params) ? params.scale : kDefaultScale;
PDFView.open(params.file || kDefaultURL, parseFloat(scale));

if (!window.File || !window.FileReader || !window.FileList || !window.Blob)
document.getElementById('fileInput').style.display = 'none';
Expand Down

0 comments on commit 7323e67

Please sign in to comment.