Skip to content

Commit

Permalink
Merge pull request #12090 from Snuffleupagus/rm-not-xobj
Browse files Browse the repository at this point in the history
Stop special-casing the (very unlikely) "no `/XObject` found"-scenario, when parsing `OPS.paintXObject` operators, in `PartialEvaluator.{getOperatorList, getTextContent}`
  • Loading branch information
timvandermeij authored Jul 13, 2020
2 parents cf0ed3c + d4d7ac1 commit 6c39aff
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
9 changes: 0 additions & 9 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1331,11 +1331,6 @@ class PartialEvaluator {
xobj = xref.fetch(xobj);
}

if (!xobj) {
operatorList.addOp(fn, args);
resolveXObject();
return;
}
if (!isStream(xobj)) {
throw new FormatError("XObject should be a stream");
}
Expand Down Expand Up @@ -2287,10 +2282,6 @@ class PartialEvaluator {
xobj = xref.fetch(xobj);
}

if (!xobj) {
resolveXObject();
return;
}
if (!isStream(xobj)) {
throw new FormatError("XObject should be a stream");
}
Expand Down
4 changes: 0 additions & 4 deletions src/display/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -2433,10 +2433,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.ctx.fillRect(0, 0, 1, 1);
},

paintXObject: function CanvasGraphics_paintXObject() {
warn("Unsupported 'paintXObject' command.");
},

// Marked content

markPoint: function CanvasGraphics_markPoint(tag) {
Expand Down
28 changes: 22 additions & 6 deletions test/unit/evaluator_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,32 @@ describe("evaluator", function () {
});

it("should handle two glued operations", function (done) {
var resources = new ResourcesMock();
resources.Res1 = {};
const imgDict = new Dict();
imgDict.set("Subtype", Name.get("Image"));
imgDict.set("Width", 1);
imgDict.set("Height", 1);

const imgStream = new Stream([0]);
imgStream.dict = imgDict;

const xObject = new Dict();
xObject.set("Res1", imgStream);

const resources = new ResourcesMock();
resources.XObject = xObject;

var stream = new StringStream("/Res1 DoQ");
runOperatorListCheck(partialEvaluator, stream, resources, function (
result
) {
expect(!!result.fnArray && !!result.argsArray).toEqual(true);
expect(result.fnArray.length).toEqual(2);
expect(result.fnArray[0]).toEqual(OPS.paintXObject);
expect(result.fnArray[1]).toEqual(OPS.restore);
expect(result.fnArray.length).toEqual(3);
expect(result.fnArray[0]).toEqual(OPS.dependency);
expect(result.fnArray[1]).toEqual(OPS.paintImageXObject);
expect(result.fnArray[2]).toEqual(OPS.restore);
expect(result.argsArray.length).toEqual(3);
expect(result.argsArray[0]).toEqual(["img_p0_1"]);
expect(result.argsArray[1]).toEqual(["img_p0_1", 1, 1]);
expect(result.argsArray[2]).toEqual(null);
done();
});
});
Expand Down

0 comments on commit 6c39aff

Please sign in to comment.