fixed text draw issue for opera

This commit is contained in:
MoyuScript
2011-07-16 23:56:49 +03:00
parent e548851114
commit 71b0727125
9 changed files with 54 additions and 22 deletions

View File

@ -22,11 +22,11 @@ html2canvas.prototype.drawBackground = function(el,bounds){
case "repeat-x":
this.drawbackgroundRepeatX(image,bgp,bounds.left,bounds.top,bounds.width,bounds.height);
break;
case "repeat-y":
this.drawbackgroundRepeatY(image,bgp,bounds.left,bounds.top,bounds.width,bounds.height);
break;
case "no-repeat":
this.drawBackgroundRepeat(image,bgp.left+bounds.left,bgp.top+bounds.top,Math.min(bounds.width,image.width),Math.min(bounds.height,image.height),bounds.left,bounds.top);

View File

@ -33,11 +33,15 @@ function html2canvas(el, userOptions) {
// test how to measure text bounding boxes
this.useRangeBounds = false;
// Check disabled as Opera doesn't provide bounds.height/bottom even though it supports the method.
// TODO take the check back into use, but fix the issue for Opera
/*
if (document.createRange){
var r = document.createRange();
this.useRangeBounds = new Boolean(r.getBoundingClientRect);
}
}*/
// Start script
this.init();
}
@ -113,6 +117,8 @@ html2canvas.prototype.start = function(){
if (this.images.length == 0 || this.imagesLoaded==this.images.length/2){
this.log('Started parsing');
this.bodyOverflow = document.getElementsByTagName('body')[0].style.overflow;
document.getElementsByTagName('body')[0].style.overflow = "hidden";
this.newElement(this.element);
this.parseElement(this.element);
@ -127,7 +133,8 @@ html2canvas.prototype.start = function(){
html2canvas.prototype.finish = function(){
this.log("Finished rendering");
document.getElementsByTagName('body')[0].style.overflow = this.bodyOverflow;
if (this.opts.renderViewport){
// let's crop it to viewport only then
var newCanvas = document.createElement('canvas');

View File

@ -98,7 +98,7 @@ html2canvas.prototype.newElement = function(el){
*/
html2canvas.prototype.printText = function(currentText,x,y){
if (this.trim(currentText).length>0){
if (this.trim(currentText).length>0){
this.ctx.fillText(currentText,x,y);
}
}
@ -106,6 +106,7 @@ html2canvas.prototype.printText = function(currentText,x,y){
// Drawing a rectangle
html2canvas.prototype.newRect = function(x,y,w,h,bgcolor){
if (bgcolor!="transparent"){
this.ctx.fillStyle = bgcolor;
this.ctx.fillRect (x, y, w, h);

View File

@ -61,13 +61,19 @@ html2canvas.prototype.newText = function(el,textNode){
wrapElement.appendChild(oldTextNode.cloneNode(true));
parent.replaceChild(wrapElement,oldTextNode);
var bounds = this.getBounds(wrapElement);
var bounds = this.getBounds(wrapElement);
parent.replaceChild(backupText,wrapElement);
}
this.printText(oldTextNode.nodeValue,bounds.left,bounds.bottom);

View File

@ -11,8 +11,9 @@
timeoutTimer,
timer = date.getTime();
new html2canvas(this.get(0),{
ready:function(canvas){
new html2canvas(this.get(0), {
loggine: true,
ready: function(canvas) {
var finishTime = new Date();
// console.log((finishTime.getTime()-timer)/1000);