JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.5.4
[ckeditor.git] / _source / core / dom / walker.js
index 126f3f2..7f430b8 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -338,7 +338,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
        CKEDITOR.dom.element.prototype.isBlockBoundary = function( customNodeNames )\r
        {\r
-               var nodeNameMatches = CKEDITOR.tools.extend( {}, CKEDITOR.dtd.$block, customNodeNames || {} );\r
+               var nodeNameMatches = customNodeNames ?\r
+                       CKEDITOR.tools.extend( {}, CKEDITOR.dtd.$block, customNodeNames || {} ) :\r
+                       CKEDITOR.dtd.$block;\r
 \r
                // Don't consider floated formatting as block boundary, fall back to dtd check in that case. (#6297)\r
                return this.getComputedStyle( 'float' ) == 'none' && blockBoundaryDisplayMatch[ this.getComputedStyle( 'display' ) ]\r
@@ -373,7 +375,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                {\r
                        return ( node && node.getName\r
                                        && node.getName() == 'span'\r
-                                       && node.hasAttribute( '_cke_bookmark' ) );\r
+                                       && node.data( 'cke-bookmark' ) );\r
                }\r
 \r
                return function( node )\r
@@ -421,18 +423,34 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                };\r
        };\r
 \r
+       CKEDITOR.dom.walker.nodeType = function( type, isReject )\r
+       {\r
+               return function( node )\r
+               {\r
+                       return !! ( isReject ^ ( node.type == type ) );\r
+               };\r
+       };\r
+\r
        var tailNbspRegex = /^[\t\r\n ]*(?: |\xa0)$/,\r
-               isNotWhitespaces = CKEDITOR.dom.walker.whitespaces( 1 ),\r
-               isNotBookmark = CKEDITOR.dom.walker.bookmark( 0, 1 ),\r
-               fillerEvaluator = function( element )\r
+               isWhitespaces = CKEDITOR.dom.walker.whitespaces(),\r
+               isBookmark = CKEDITOR.dom.walker.bookmark(),\r
+               toSkip = function( node )\r
                {\r
-                       return isNotBookmark( element ) && isNotWhitespaces( element );\r
+                       return isBookmark( node )\r
+                                       || isWhitespaces( node )\r
+                                       || node.type == CKEDITOR.NODE_ELEMENT\r
+                                       && node.getName() in CKEDITOR.dtd.$inline\r
+                                       && !( node.getName() in CKEDITOR.dtd.$empty );\r
                };\r
 \r
        // Check if there's a filler node at the end of an element, and return it.\r
        CKEDITOR.dom.element.prototype.getBogus = function()\r
        {\r
-               var tail = this.getLast( fillerEvaluator );\r
+               // Bogus are not always at the end, e.g. <p><a>text<br /></a></p> (#7070).\r
+               var tail = this;\r
+               do { tail = tail.getPreviousSourceNode(); }\r
+               while ( toSkip( tail ) )\r
+\r
                if ( tail && ( !CKEDITOR.env.ie ? tail.is && tail.is( 'br' )\r
                                : tail.getText && tailNbspRegex.test( tail.getText() ) ) )\r
                {\r