Ticket #3051: 3051_2.patch
File 3051_2.patch, 5.1 KB (added by , 14 years ago) |
---|
-
_source/core/dom/walker.js
53 53 if ( node == this.endNode && !this.endInclusive ) 54 54 break; 55 55 56 if ( !this.evaluator &&this.evaluator( node ) !== false )56 if ( !this.evaluator || this.evaluator( node ) !== false ) 57 57 return node; 58 58 else if ( breakOnFalse && this.evaluator ) 59 59 return false; … … 67 67 68 68 function iterateToLast( rtl ) 69 69 { 70 var node, last ;70 var node, last = null; 71 71 72 72 while ( node = iterate.call( this, rtl ) ) 73 73 last = node; -
_source/core/dom/range.js
1084 1084 case CKEDITOR.ENLARGE_BLOCK_CONTENTS: 1085 1085 case CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS: 1086 1086 // DFS backward to get the block/list item boundary at or before the start. 1087 1088 // Get the boundaries nodes.1089 var startNode = this.getTouchedStartNode(),1090 endNode = this.getTouchedEndNode();1091 1092 if ( startNode.type == CKEDITOR.NODE_ELEMENT && startNode.isBlockBoundary())1087 // Get the outter boundaries nodes. 1088 var startNode, endNode; 1089 1090 // Use bookmark nodes to mock boundary nodes for collapsed 1091 // range. 1092 if( this.collapsed ) 1093 1093 { 1094 this.setStartAt( startNode, 1095 CKEDITOR.dtd.$empty[ startNode.getName() ] ? 1096 CKEDITOR.POSITION_AFTER_END : 1097 CKEDITOR.POSITION_AFTER_START ); 1094 var bm = this.createBookmark(); 1095 startNode= bm.startNode; 1096 endNode = startNode; 1098 1097 } 1099 1098 else 1100 1099 { 1101 // Get the function used to check the enlaarging limits. 1102 var guardFunction = ( unit == CKEDITOR.ENLARGE_BLOCK_CONTENTS ? 1103 CKEDITOR.dom.domWalker.blockBoundary() : 1104 CKEDITOR.dom.domWalker.listItemBoundary() ); 1105 1106 // Create the DOM walker, which will traverse the DOM. 1107 var walker = new CKEDITOR.dom.domWalker( startNode ); 1100 var boundaries = this.getBoundaryNodes(), 1101 startNode = boundaries.startNode, 1102 endNode = boundaries.endNode; 1103 } 1108 1104 1109 // Go walk in reverse sense. 1110 var data = walker.reverse( guardFunction ); 1111 1112 var boundaryEvent = data.events.shift(); 1105 // function used to check the enlarging limits. 1106 function checkOnBoundary( toNode, fromNode, customNodeNames ) 1107 { 1108 // Check the enlarged node. 1109 if( toNode && toNode.type == CKEDITOR.NODE_ELEMENT 1110 && toNode.isBlockBoundary( 1111 unit == CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS? { br : 1 } : null ) ) 1112 return true; 1113 1113 1114 this.setStartBefore( boundaryEvent.from ); 1114 // Check the current node. 1115 else if( currentNode.type == CKEDITOR.NODE_ELEMENT && 1116 currentNode.isBlockBoundary( 1117 unit == CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS? { br : 1 } : null ) 1118 && ( enlargedNode.$ == currentNode.$.parentNode 1119 || enlargedNode.$ == currentNode.$.previousSibling ) ) 1120 return true; 1115 1121 } 1116 1117 if ( endNode.type == CKEDITOR.NODE_ELEMENT && endNode.isBlockBoundary() ) 1122 1123 // Enlarging the start boundary. 1124 var walker = new CKEDITOR.dom.walker( startNode ), 1125 enlargedNode = startNode, 1126 currentNode = enlargedNode; 1127 while( enlargedNode ) 1118 1128 { 1119 this.setEndAt( endNode, 1120 CKEDITOR.dtd.$empty[ endNode.getName() ] ? 1121 CKEDITOR.POSITION_BEFORE_START : 1122 CKEDITOR.POSITION_BEFORE_END ); 1129 // Check for those opening element. 1130 if( !currentNode.getPrevious() && 1131 checkOnBoundary( currentNode.getParent(), currentNode ) ) 1132 break; 1133 enlargedNode = walker.previous(); 1134 if( checkOnBoundary( enlargedNode, currentNode ) ) 1135 break; 1136 currentNode = enlargedNode; 1123 1137 } 1124 else 1138 this.setStartAt( enlargedNode, CKEDITOR.POSITION_AFTER_END ); 1139 1140 // Enlarging the end boundary. 1141 walker = new CKEDITOR.dom.walker( endNode ), 1142 enlargedNode = endNode, 1143 currentNode = enlargedNode; 1144 while( enlargedNode ) 1125 1145 { 1126 // DFS forward to get the block/list item boundary at or before the end. 1127 walker.setNode( endNode ); 1128 data = walker.forward( guardFunction ); 1129 boundaryEvent = data.events.shift(); 1130 1131 this.setEndAfter( boundaryEvent.from ); 1146 // Check for those closing element. 1147 if( !currentNode.getNext() && 1148 checkOnBoundary( currentNode.getParent(), currentNode ) ) 1149 break; 1150 enlargedNode = walker.next(); 1151 if( checkOnBoundary( enlargedNode, currentNode ) ) 1152 break; 1153 currentNode = enlargedNode; 1154 } 1155 this.setEndAt( enlargedNode, CKEDITOR.POSITION_BEFORE_START ); 1156 1157 if( bm ) 1158 { 1159 // Backup current range. 1160 var enlargedBm = this.createBookmark(); 1161 1162 // Destroy the marker bookmark. 1163 this.moveToBookmark( bm ); 1164 this.moveToBookmark( enlargedBm ); 1132 1165 } 1133 1166 } 1134 1167 },