JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.3.2
[ckeditor.git] / _source / plugins / domiterator / plugin.js
index a7a8e4d..dcb592d 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -11,8 +11,10 @@ CKEDITOR.plugins.add( 'domiterator' );
 \r
 (function()\r
 {\r
-\r
-       var iterator = function( range )\r
+       /**\r
+        * @name CKEDITOR.dom.iterator\r
+        */\r
+       function iterator( range )\r
        {\r
                if ( arguments.length < 1 )\r
                        return;\r
@@ -25,9 +27,10 @@ CKEDITOR.plugins.add( 'domiterator' );
                this.enforceRealBlocks = false;\r
 \r
                this._ || ( this._ = {} );\r
-       },\r
-               beginWhitespaceRegex = /^[\r\n\t ]+$/;\r
+       }\r
 \r
+       var beginWhitespaceRegex = /^[\r\n\t ]+$/,\r
+               isBookmark = CKEDITOR.dom.walker.bookmark();\r
 \r
        iterator.prototype = {\r
                getNextParagraph : function( blockTag )\r
@@ -48,6 +51,10 @@ CKEDITOR.plugins.add( 'domiterator' );
                        if ( !this._.lastNode )\r
                        {\r
                                range = this.range.clone();\r
+\r
+                               // Shrink the range to exclude harmful "noises" (#4087, #4450, #5435).\r
+                               range.shrink( CKEDITOR.NODE_ELEMENT, true );\r
+\r
                                range.enlarge( this.forceBrBreak || !this.enlargeBr ?\r
                                                           CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS : CKEDITOR.ENLARGE_BLOCK_CONTENTS );\r
 \r
@@ -209,28 +216,8 @@ CKEDITOR.plugins.add( 'domiterator' );
 \r
                                // We have found a block boundary. Let's close the range and move out of the\r
                                // loop.\r
-                               if ( ( closeRange || isLast ) && range )\r
-                               {\r
-                                       var boundaryNodes = range.getBoundaryNodes(),\r
-                                               startPath = new CKEDITOR.dom.elementPath( range.startContainer ),\r
-                                               endPath = new CKEDITOR.dom.elementPath( range.endContainer );\r
-\r
-                                       // Drop the range if it only contains bookmark nodes.(#4087)\r
-                                       if ( boundaryNodes.startNode.equals( boundaryNodes.endNode )\r
-                                               && boundaryNodes.startNode.getParent().equals( startPath.blockLimit )\r
-                                               && boundaryNodes.startNode.type == CKEDITOR.NODE_ELEMENT\r
-                                               && boundaryNodes.startNode.getAttribute( '_fck_bookmark' ) )\r
-                                       {\r
-                                               range = null;\r
-                                               this._.nextNode = null;\r
-                                       }\r
-                                       else\r
+                               if ( isLast || ( closeRange && range ) )\r
                                                break;\r
-                               }\r
-\r
-                               if ( isLast )\r
-                                       break;\r
-\r
                        }\r
 \r
                        // Now, based on the processed range, look for (or create) the block to be returned.\r
@@ -244,7 +231,7 @@ CKEDITOR.plugins.add( 'domiterator' );
                                        return null;\r
                                }\r
 \r
-                               startPath = new CKEDITOR.dom.elementPath( range.startContainer );\r
+                               var startPath = new CKEDITOR.dom.elementPath( range.startContainer );\r
                                var startBlockLimit = startPath.blockLimit,\r
                                        checkLimits = { div : 1, th : 1, td : 1 };\r
                                block = startPath.block;\r