Changeset 12925


Ignore:
Timestamp:
03/01/09 19:56:52 (3 years ago)
Author:
sys
Message:

textPrim editor : suppr appel HTMLEditor.insertNode -> perf catastrophiques sur insertions volumineuses (coller imposants)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Xul_XedLib/chrome/content/scenarixedlib/libUiExtra/scRichText/textBase.xbl.xml

    r12924 r12925  
    165165                                                                                if(pInTransaction) { 
    166166                                                                                        this.insertElt(vPara, vNode, null); 
    167                                                                                         //this.fHTMLEditor.insertNode(vPara, vNode, 0); 
    168167                                                                                } else { 
    169168                                                                                        vNode.appendChild(this.createPara()); 
     
    178177                                                                                        if(pInTransaction) { 
    179178                                                                                                this.insertElt(vCaption, vNode, vNode.firstChild); 
    180                                                                                                 //this.fHTMLEditor.insertNode(vCaption, vNode, 0); 
    181179                                                                                        } else { 
    182180                                                                                                vNode.insertBefore(vCaption, vNode.firstChild); 
     
    190188                                                                                        if(pInTransaction) { 
    191189                                                                                                this.insertElt(vCol, vNode, vCaption ? vCaption.nextSibling : vNode.firstChild); 
    192                                                                                                 //this.fHTMLEditor.insertNode(vCol, vNode, vCaption ? 1 : 0); 
    193190                                                                                        } else { 
    194191                                                                                                vNode.insertBefore(vCol, vCaption ? vCaption.nextSibling : vNode.firstChild); 
     
    202199                                                                                        if(pInTransaction) { 
    203200                                                                                                this.insertElt(vTR, vNode, null); 
    204                                                                                                 //this.fHTMLEditor.insertNode(vTR, vNode, vNode.childNodes.length); 
    205201                                                                                        } else { 
    206202                                                                                                vNode.appendChild(vTR); 
     
    220216                                                                                                if(pInTransaction) { 
    221217                                                                                                        this.insertElt(vNewTD, vNode, null); 
    222                                                                                                         //this.fHTMLEditor.insertNode(vNewTD, vNode, vNode.childNodes.length); 
    223218                                                                                                } else { 
    224219                                                                                                        vNode.appendChild(vNewTD); 
     
    244239                                                                if( ! vNode.hasChildNodes() || vNode.lastChild.nodeName!="BR") { 
    245240                                                                        if(pInTransaction) { 
    246                                                                                 this.fHTMLEditor.insertNode(vDoc.createElement("BR"), vNode, vNode.childNodes.length); 
     241                                                                                this.insertElt(vDoc.createElement("BR"), vNode, null); 
    247242                                                                        } else { 
    248243                                                                                vNode.appendChild(vDoc.createElement("BR")); 
     
    24532448                                                if(pRole) vTR.setAttribute("role", pRole); 
    24542449                                                this.insertElt(vTR, pTable, pBefore); 
    2455                                                 //this.fHTMLEditor.insertNode(vTR, pTable, pBefore ? this.getOffsetInParent(pBefore) : pTable.childNodes.length); 
    24562450                                                this.checkForEdit(vTR, true); 
    24572451                                        } 
     
    37503744                                                                                                if(vCh.nodeName != "BR") { 
    37513745                                                                                                        this.deleteElt(vCh); 
    3752                                                                                                         this.fHTMLEditor.insertNode(vCh, vReceiver, vReceiver.childNodes.length - 1); 
     3746                                                                                                        this.insertElt(vCh, vReceiver, vReceiver.lastChild); 
    37533747                                                                                                } 
    37543748                                                                                                vCh = vNext; 
     
    40474041                                ]]></body> 
    40484042                        </method> 
     4043                        <!-- Transaction pour l'insertion d'un tableau de noeuds. --> 
     4044                        <method name="insertElts"> 
     4045                                <parameter name="pNodes"/> 
     4046                                <parameter name="pParent"/> 
     4047                                <parameter name="pBefore"/> 
     4048                                <body><![CDATA[ 
     4049                                        var vTrans = {  fNodes : pNodes,  
     4050                                                                        fParent : pParent,  
     4051                                                                        fNext : pBefore, 
     4052                                                                        merge : function(pTrans){return false;}, 
     4053                                                                        isTransient : false 
     4054                                                                }; 
     4055                                         
     4056                                        vTrans.doTransaction = function(){ 
     4057                                                for(var i = 0; i < this.fNodes.length; i++) { 
     4058                                                        this.fParent.insertBefore(this.fNodes[i], this.fNext); 
     4059                                                } 
     4060                                        } 
     4061                                        vTrans.undoTransaction = function(){ 
     4062                                                for(var i = this.fNodes.length - 1; i >=0 ; i--) { 
     4063                                                        this.fParent.removeChild(this.fNodes[i]); 
     4064                                                } 
     4065                                        } 
     4066                                        vTrans.redoTransaction = function(){ 
     4067                                                this.doTransaction(); 
     4068                                        } 
     4069                                        this.fHTMLEditor.doTransaction(vTrans); 
     4070                                ]]></body> 
     4071                        </method> 
    40494072                        <!-- Transaction pour replacer la sélection sur un undo --> 
    40504073                        <method name="addTransSelForUndo"> 
     
    41834206                                        //On insert le texte 
    41844207                                        if(pParent.nodeType == 1) { 
    4185                                                 //On est pas dans un text, on cherche un frère de type text 
     4208                                                //On n'est pas dans un text, on cherche un frère de type text 
    41864209                                                var vNode = pParent.childNodes[pOffset]; 
    41874210                                                if(vNode && vNode.nodeType == 3) { 
     
    41954218                                                        } else { 
    41964219                                                                //Pas de noeud text autour, on crée un nouveau noeud. 
    4197                                                                 this.fHTMLEditor.insertNode(this.fHTMLEditor.document.createTextNode(pCdata), pParent, pOffset); 
     4220                                                                this.insertElt(this.fHTMLEditor.document.createTextNode(pCdata), pParent, pParent.childNodes[pOffset]); 
    41984221                                                                return; 
    41994222                                                        } 
     
    46994722                                                                //On transforme tous les parablocks/textblock pour les insérer en member de la liste 
    47004723                                                                var vThis = this; 
    4701                                                                 var vInserted = 0; 
     4724                                                                var vNodeToInsert = []; 
    47024725                                                                function insertBlock(pXmlParent) { 
    4703                                                                         var vCh = pXmlParent.lastChild; 
     4726                                                                        var vCh = pXmlParent.firstChild; 
    47044727                                                                        while(vCh) { 
    47054728                                                                                var vClass = vThis.fClasses._xml[vCh.localName]; 
     
    47124735                                                                                                vThis.xml2html(vCh, vNewPara, pEraseId, vElParent); 
    47134736                                                                                                vThis.checkForEdit(vNewPara, false); 
    4714                                                                                                 vThis.fHTMLEditor.insertNode(vNewPara, vElParent, pOffset); 
    4715                                                                                                 vInserted++; 
     4737                                                                                                vNodeToInsert.push(vNewPara); 
    47164738                                                                                                //xed.debug("result::\n"+xed.getXml(vNewPara)); 
    47174739                                                                                        } else if(vClass.type==6) { 
     
    47204742                                                                                        } 
    47214743                                                                                } 
    4722                                                                                 vCh = vCh.previousSibling; 
     4744                                                                                vCh = vCh.nextSibling; 
    47234745                                                                        } 
    47244746                                                                } 
    47254747                                                                insertBlock(pNodeRoot); 
    4726                                                                 if(vInserted>0) { 
     4748                                                                if(vNodeToInsert.length>0) { 
     4749                                                                        this.insertElts(vNodeToInsert, vElParent, vElParent.childNodes.item(pOffset)); 
    47274750                                                                        var vRange = this.fHTMLEditor.document.createRange(); 
    47284751                                                                        vRange.setStart(pParent, pOffset); 
    4729                                                                         vRange.setEnd(pParent, pOffset+vInserted); 
     4752                                                                        vRange.setEnd(pParent, pOffset + vNodeToInsert.length); 
    47304753                                                                        return vRange; 
    47314754                                                                } else return null; 
     
    47504773                                                                        var vRange = this.fHTMLEditor.document.createRange(); 
    47514774                                                                        vRange.setStart(vElParent, pOffset); 
    4752                                                                         var vInserted = 0; 
    4753                                                                         while(vFrag.hasChildNodes()) { 
    4754                                                                                 this.fHTMLEditor.insertNode(vFrag.lastChild, vElParent, pOffset); 
    4755                                                                                 vInserted++; 
    4756                                                                         } 
    4757                                                                         vRange.setEnd(vElParent, pOffset+vInserted); 
     4775                                                                        var vNodeToInsert = []; 
     4776                                                                        while(vFrag.hasChildNodes()) vNodeToInsert.push(vFrag.removeChild(vFrag.firstChild)); 
     4777                                                                        this.insertElts(vNodeToInsert, vElParent, vElParent.childNodes.item(pOffset)); 
     4778                                                                        vRange.setEnd(vElParent, pOffset + vNodeToInsert.length); 
    47584779                                                                        return vRange; 
    47594780                                                                } 
Note: See TracChangeset for help on using the changeset viewer.