Changeset 12594

Show
Ignore:
Timestamp:
02/21/08 11:09:52 (11 months ago)
Author:
elazutkin
Message:

Preventing IE from allocating large memory chunks for images in
cases of trivial transformations (scaling + translating).
Fixes #5852, !strict

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • dojox/trunk/gfx/vml.js

    r11996 r12594  
    432432                var shape = this.shape = dojox.gfx.makeParameters(this.shape, newShape); 
    433433                this.bbox = null; 
    434                 var firstChild = this.rawNode.firstChild; 
    435         firstChild.src = shape.src; 
    436         if(shape.width || shape.height){ 
    437                         firstChild.style.width  = shape.width; 
    438                         firstChild.style.height = shape.height; 
    439         } 
     434                this.rawNode.firstChild.src = shape.src; 
    440435                return this.setTransform(this.matrix);  // self 
    441436        }, 
     437        _setDimensions: function(s, w, h){ 
     438                if(w || h){ 
     439                        s.width  = w + "px"; 
     440                        s.height = h + "px"; 
     441                } 
     442        }, 
     443        _resetImage: function(){ 
     444                var s = this.rawNode.firstChild.style, 
     445                        shape = this.shape; 
     446                s.left = "0px"; 
     447                s.top  = "0px"; 
     448                this._setDimensions(s, shape.width, shape.height); 
     449        }, 
    442450        _applyTransform: function() { 
    443                 var matrix = this._getRealMatrix(); 
    444                 if(!matrix) return this; 
    445                 matrix = dojox.gfx.matrix.multiply(matrix, {dx: this.shape.x, dy: this.shape.y}); 
    446                 var f = this.rawNode.filters["DXImageTransform.Microsoft.Matrix"]; 
    447                 f.M11 = matrix.xx; 
    448                 f.M12 = matrix.xy; 
    449                 f.M21 = matrix.yx; 
    450                 f.M22 = matrix.yy; 
    451                 f.Dx  = matrix.dx; 
    452                 f.Dy  = matrix.dy; 
     451                var matrix = this._getRealMatrix(), 
     452                        img = this.rawNode.firstChild, 
     453                        s = img.style, 
     454                        shape = this.shape; 
     455                if(matrix){ 
     456                        matrix = dojox.gfx.matrix.multiply(matrix, {dx: shape.x, dy: shape.y}); 
     457                }else{ 
     458                        matrix = dojox.gfx.matrix.normalize({dx: shape.x, dy: shape.y}); 
     459                } 
     460                if(matrix.xy == 0 && matrix.yx == 0 && matrix.xx > 0 && matrix.yy > 0){ 
     461                        // special case to avoid filters 
     462                        this.rawNode.style.filter = ""; 
     463                        s.left = Math.floor(matrix.dx) + "px"; 
     464                        s.top  = Math.floor(matrix.dy) + "px"; 
     465                        this._setDimensions(s, Math.floor(matrix.xx * shape.width), Math.floor(matrix.yy * shape.height)); 
     466                }else{ 
     467                        this._resetImage(); 
     468                        var f = this.rawNode.filters["DXImageTransform.Microsoft.Matrix"]; 
     469                        if(f){ 
     470                                f.M11 = matrix.xx; 
     471                                f.M12 = matrix.xy; 
     472                                f.M21 = matrix.yx; 
     473                                f.M22 = matrix.yy; 
     474                                f.Dx = matrix.dx; 
     475                                f.Dy = matrix.dy; 
     476                        }else{ 
     477                                this.rawNode.style.filter = "progid:DXImageTransform.Microsoft.Matrix(M11=" + matrix.xx +  
     478                                        ", M12=" + matrix.xy + ", M21=" + matrix.yx + ", M22=" + matrix.yy +  
     479                                        ", Dx=" + matrix.dx + ", Dy=" + matrix.dy + ")"; 
     480                        } 
     481                } 
    453482                return this; 
    454483        } 
     
    10791108                node.style.width  = this.rawNode.style.width; 
    10801109                node.style.height = this.rawNode.style.height; 
    1081                 node.style.filter = "progid:DXImageTransform.Microsoft.Matrix(M11=1, M12=0, M21=0, M22=1, Dx=0, Dy=0)"; 
     1110                //node.style.filter = "progid:DXImageTransform.Microsoft.Matrix(M11=1, M12=0, M21=0, M22=1, Dx=0, Dy=0)"; 
    10821111                var img  = this.rawNode.ownerDocument.createElement('img'); 
     1112                img.style.position = "relative"; 
    10831113                node.appendChild(img); 
    10841114                shape.setRawNode(node);