JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.6.1
[ckeditor.git] / _source / core / dom / walker.js
index 3d19425..569ac57 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -413,8 +413,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
        {\r
                return function( node )\r
                {\r
-                       var isWhitespace = node && ( node.type == CKEDITOR.NODE_TEXT )\r
-                                                       && !CKEDITOR.tools.trim( node.getText() );\r
+                       var isWhitespace;\r
+                       if ( node && node.type == CKEDITOR.NODE_TEXT )\r
+                       {\r
+                               // whitespace, as well as the text cursor filler node we used in Webkit. (#9384)\r
+                               isWhitespace = !CKEDITOR.tools.trim( node.getText() ) ||\r
+                                       CKEDITOR.env.webkit && node.getText() == '\u200b';\r
+                       }\r
+\r
                        return !! ( isReject ^ isWhitespace );\r
                };\r
        };\r
@@ -428,13 +434,25 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                var whitespace = CKEDITOR.dom.walker.whitespaces();\r
                return function( node )\r
                {\r
-                       // Nodes that take no spaces in wysiwyg:\r
-                       // 1. White-spaces but not including NBSP;\r
-                       // 2. Empty inline elements, e.g. <b></b> we're checking here\r
-                       // 'offsetHeight' instead of 'offsetWidth' for properly excluding\r
-                       // all sorts of empty paragraph, e.g. <br />.\r
-                       var isInvisible = whitespace( node ) || node.is && !node.$.offsetHeight;\r
-                       return !! ( isReject ^ isInvisible );\r
+                       var invisible;\r
+\r
+                       if ( whitespace( node ) )\r
+                               invisible = 1;\r
+                       else\r
+                       {\r
+                               // Visibility should be checked on element.\r
+                               if ( node.type == CKEDITOR.NODE_TEXT )\r
+                                       node = node.getParent();\r
+\r
+                               // Nodes that take no spaces in wysiwyg:\r
+                               // 1. White-spaces but not including NBSP;\r
+                               // 2. Empty inline elements, e.g. <b></b> we're checking here\r
+                               // 'offsetHeight' instead of 'offsetWidth' for properly excluding\r
+                               // all sorts of empty paragraph, e.g. <br />.\r
+                               invisible = !node.$.offsetHeight;\r
+                       }\r
+\r
+                       return !! ( isReject ^ invisible );\r
                };\r
        };\r
 \r
@@ -446,7 +464,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                };\r
        };\r
 \r
-       CKEDITOR.dom.walker.bogus = function( type, isReject )\r
+       CKEDITOR.dom.walker.bogus = function( isReject )\r
        {\r
                function nonEmpty( node )\r
                {\r
@@ -455,11 +473,17 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
                return function( node )\r
                {\r
-                       var parent = node.getParent(),\r
-                               isBogus = !CKEDITOR.env.ie ? node.is && node.is( 'br' ) :\r
+                       var isBogus = !CKEDITOR.env.ie ? node.is && node.is( 'br' ) :\r
                                          node.getText && tailNbspRegex.test( node.getText() );\r
 \r
-                       isBogus = isBogus && parent.isBlockBoundary() && !!parent.getLast( nonEmpty );\r
+                       if ( isBogus )\r
+                       {\r
+                               var parent = node.getParent(), next = node.getNext( nonEmpty );\r
+                               isBogus = parent.isBlockBoundary() &&\r
+                                         ( !next ||\r
+                                           next.type == CKEDITOR.NODE_ELEMENT &&\r
+                                           next.isBlockBoundary() );\r
+                       }\r
 \r
                        return !! ( isReject ^ isBogus );\r
                };\r