background-size fixes

generated gradients need a unique key (the same value can generate a
different image based on background-size); fix so that a single value
specified for background-size yields a scaled height as the second
parameter
This commit is contained in:
Andy Edinborough
2013-01-02 14:51:03 -06:00
parent eb57b61859
commit 7da4326885
3 changed files with 44 additions and 22 deletions

View File

@ -90,6 +90,7 @@ _html2canvas.Preload = function( options ) {
}
function getImages (el) {
el.__html2canvas__id = uid++;
var contents = _html2canvas.Util.Children(el),
i,
@ -97,6 +98,7 @@ _html2canvas.Preload = function( options ) {
background_images,
src,
img,
bounds,
elNodeType = false;
// Firefox fails with permission denied on pages with iframes
@ -125,7 +127,9 @@ _html2canvas.Preload = function( options ) {
}
background_images = _html2canvas.Util.parseBackgroundImage(background_image);
while(!!(background_image = background_images.shift())) {
for(var imageIndex = background_images.length; imageIndex-- > 0;) {
background_image = background_images[imageIndex];
if(!background_image ||
!background_image.method ||
!background_image.args ||
@ -138,17 +142,21 @@ _html2canvas.Preload = function( options ) {
methods.loadImage(src);
} else if( background_image.method.match( /\-gradient$/ ) ) {
img = _html2canvas.Generate.Gradient( background_image.value, _html2canvas.Util.Bounds( el ) );
if(bounds === undefined) {
bounds = _html2canvas.Util.Bounds( el );
}
var key = background_image.value + '/' + el.__html2canvas__id + '/' + imageIndex;
img = _html2canvas.Generate.Gradient( background_image.value, bounds);
if ( img !== undefined ){
images[background_image.value] = {
images[ key ] = {
img: img,
succeeded: true
};
images.numTotal++;
images.numLoaded++;
start();
}
}
}
@ -216,7 +224,7 @@ _html2canvas.Preload = function( options ) {
return;
}
if(!el.id) {
el.id = '__html2cavas__' + (uid++);
el.id = '__html2canvas__' + (uid++);
}
if(!injectStyle) {
injectStyle = document.createElement('style');
@ -382,7 +390,7 @@ _html2canvas.Preload = function( options ) {
.forEach(removePseudoElements);
}
},
renderingDone: function() {
if (timeoutTimer) {
window.clearTimeout(timeoutTimer);