Ticket #4073: 4073.patch
File 4073.patch, 4.6 KB (added by , 15 years ago) |
---|
-
_test/dt/core/dom/range.html
1062 1067 */ 1063 1068 test_enlarge_block6 : function() 1064 1069 { 1065 var range = getRange( 'S11' , null);1070 var range = getRange( 'S11' ); 1066 1071 range.enlarge( CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS ); 1067 1072 1068 1073 assert.areSame( document.getElementById( '_EnlargeP17' ), … … 1070 1075 assert.areSame( 0, range.startOffset, 'range.startOffset' ); 1071 1076 }, 1072 1077 1078 /** 1079 * Test enlarge block when there's no nodes to enlarge. 1080 */ 1081 test_enlarge_block7 : function() 1082 { 1083 var range = getRange( 'S12' ); 1084 range.enlarge( CKEDITOR.ENLARGE_BLOCK_CONTENTS ); 1085 var frag = range.extractContents(), 1086 tmp = new CKEDITOR.dom.element( 'div' ); 1087 tmp.append( frag ); 1088 assert.areSame( '<span>test block</span>', CKEDITOR.test.getInnerHtml( tmp ) ); 1089 }, 1090 1073 1091 test_deleteContents_W3C_1 : function() 1074 1092 { 1075 1093 // W3C DOM Range Specs - Section 2.6 - Example 1 … … 2385 2403 <p id="_EnlargeP4">Test <i id="_EnlargeI4"> Enlarge</i></p> 2386 2404 <p id="_EnlargeP5">Test <i id="_EnlargeI5">Enlarge</i></p> 2387 2405 <p id="_EnlargeP6">Test <i id="_EnlargeI6"><b></b>Enlarge</i></p> 2388 <p id="_EnlargeP7">Test <span id="S1"></span>List<br />Item Enlarge</p>2406 <p id="_EnlargeP7">Test <span id="S1"></span>List<br />Item Enlarge</p> 2389 2407 <p id="_EnlargeP8">Test <span id="S2"></span>List<span id="E2"></span> <br /><br />Item Enlarge</p> 2390 2408 <p id="_EnlargeP9">Test List <br /><span id="S3"></span><br />Item Enlarge</p> 2391 2409 <p id="_EnlargeP10">Test List <br /><br />Item<span id="S4"></span> Enlarge</p> … … 2393 2411 <div id="_EnlargeP12">Test<span id="S6"></span> Block <div>Enlarge</div></div> 2394 2412 <div>Test <div id="_EnlargeP13">Blo<span id="S7"></span>ck</div> Enlarge</div> 2395 2413 <p id="_EnlargeP14"><span id="S8"></span></p> 2396 <p id="_EnlargeP15">Test <span id="S9"></span>List<br />Item Enlarge</p>2414 <p id="_EnlargeP15">Test <span id="S9"></span>List<br />Item Enlarge</p> 2397 2415 <p id="_EnlargeP16">Test <strong>Block<span id="S10"></span></strong><br /><br />Enlarge</p> 2398 <p id="_EnlargeP17"><span><span id="S11"></span>Test Block Enlarge<span id="E11"></span></span></p> 2416 <p id="_EnlargeP17"><span><span id="S11"></span>Test Block Enlarge</span></p> 2417 <div id="_EnlargeP18"><span>Test Block</span><span id="S12"></span><p> Enlarge</p></div> 2399 2418 <p id="_trim_ct">Test trim</p> 2400 2419 </div> 2401 2420 <script type="text/javascript"> -
_source/core/dom/range.js
1173 1173 1174 1174 walker.guard = boundaryGuard; 1175 1175 1176 enlargeable = walker.lastBackward(); 1176 // Take the range end container if there's no 1177 // nodes to enlarge( #4073 ). 1178 enlargeable = walker.lastBackward() || walkerRange.endContainer; 1177 1179 1178 1180 // It's the body which stop the enlarging if no block boundary found. 1179 1181 blockBoundary = blockBoundary || body; 1180 1182 1181 1183 // Start the range at different position by comparing 1182 1184 // the document position of it with 'enlargeable' node. 1183 this.setStartAt( 1184 blockBoundary, 1185 this.setStartAt( blockBoundary, 1185 1186 !blockBoundary.is( 'br' ) && 1186 ( !enlargeable || blockBoundary.contains( enlargeable ) ) ? 1187 ( blockBoundary.contains( enlargeable ) 1188 || blockBoundary.equals( enlargeable ) ) ? 1187 1189 CKEDITOR.POSITION_AFTER_START : 1188 1190 CKEDITOR.POSITION_AFTER_END ); 1189 1191 … … 1199 1201 blockBoundary = null; 1200 1202 // End the range right before the block boundary node. 1201 1203 1202 enlargeable = walker.lastForward(); 1204 // Take the range start container if there's no 1205 // nodes to enlarge( #4073 ). 1206 enlargeable = walker.lastForward() || walkerRange.startContainer; 1203 1207 1204 1208 // It's the body which stop the enlarging if no block boundary found. 1205 1209 blockBoundary = blockBoundary || body; 1206 1210 1207 1211 // Start the range at different position by comparing 1208 1212 // the document position of it with 'enlargeable' node. 1209 this.setEndAt( 1210 blockBoundary, 1213 this.setEndAt( blockBoundary, 1211 1214 !blockBoundary.is( 'br' ) && 1212 ( !enlargeable || blockBoundary.contains( enlargeable ) ) ? 1215 ( blockBoundary.contains( enlargeable ) 1216 || blockBoundary.equals( enlargeable ) ) ? 1213 1217 CKEDITOR.POSITION_BEFORE_END : 1214 1218 CKEDITOR.POSITION_BEFORE_START ); 1215 1219 // We must include the <br> at the end of range if there's