{"issue":{"state":"open","created_at":"2011-11-22T20:13:18Z","updated_at":"2011-11-25T17:23:19Z","user":{"gravatar_id":"15354055d20592036cf71d436762ee5b","id":191719,"url":"https://api.github.com/users/jviereck","login":"jviereck","avatar_url":"https://secure.gravatar.com/avatar/15354055d20592036cf71d436762ee5b?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"comments":10,"body":"# Implement ctx.mozCurrentTransform and ctx.mozCurrentTransformInverse shim\r\n\r\n\r\nThis adds a shim for browsers that don't support `ctx.mozCurrentTransform` and `ctx.mozCurrentTransformInverse` by doing the required competitions in JS. This is required to make text selection work in browsers, that don't implement these Mozilla/Gecko extension to the HTML Canvas spec.\r\n\r\nSome quick measurements showed, that this slows down the rendering execution around 20-30ms on Chrome per page, which doesn't sound too bad.\r\n\r\n---\r\n\r\nThe question is where to place this code. I talked to Artur about this and he is for placing this code in `compability.js`, as it adds compability to old browsers. However, if we add the code there, we basically have to add these functions to every canvas, which requires hacking the `HTMLCanvasElement.prototype.getContext` function to return a context, that has the new `ctx.mozCurrentTransform` and `ctx.mozCurrentTransformInverse` if it's not there by default.\r\n\r\nMessing around with the prototype of a HTML element feels wrong to me. Also, this functionality gets added for every canvas in the current browser window, which might have side effects people using PDF.JS don't want (slow down of other canvas operations, that don't have anything to do with PDF.JS).\r\n\r\nFor that reason, I placed the code right now in the `canvas.js` file.\r\n\r\n@brendandahl, @notmasteryet, can you please drop your opinion on this?","assignee":null,"id":2322467,"pull_request":{"patch_url":"https://github.com/mozilla/pdf.js/pull/829.patch","html_url":"https://github.com/mozilla/pdf.js/pull/829","diff_url":"https://github.com/mozilla/pdf.js/pull/829.diff"},"labels":[],"number":829,"title":"Implement ctx.mozCurrentTransform and ctx.mozCurrentTransformInverse shim","closed_at":null,"html_url":"https://github.com/mozilla/pdf.js/issues/829","url":"https://api.github.com/repos/mozilla/pdf.js/issues/829","milestone":null},"action":"created","comment":{"created_at":"2011-11-25T17:23:19Z","updated_at":"2011-11-25T17:23:19Z","user":{"gravatar_id":"194a5ca5f2ada3125fdea6ec9dfa5fe4","id":146979,"url":"https://api.github.com/users/notmasteryet","login":"notmasteryet","avatar_url":"https://secure.gravatar.com/avatar/194a5ca5f2ada3125fdea6ec9dfa5fe4?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"That's true: the pdf.js has to know about passing mozCurrentTransforms as arguments. I don't think there are many places in the core pdf.js when getContext() is called and will appear in the future. Hopefully we will remove that later when 'moz' prefix will go away and all browsers will have currentTransform and currentTransformInverse properties.","id":2876436,"url":"https://api.github.com/repos/mozilla/pdf.js/issues/comments/2876436"}}