X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=_source%2Fcore%2Fdom%2Fwalker.js;h=126f3f205819972d2dfc656dcc7a83530d41293c;hb=refs%2Ftags%2Fv3.4.3;hp=4617a81ccc5637e352880f5899f25a8e434f22cb;hpb=ea7e3453c7b0f023b050aca6d9f83ab372860d91;p=ckeditor.git
diff --git a/_source/core/dom/walker.js b/_source/core/dom/walker.js
index 4617a81..126f3f2 100644
--- a/_source/core/dom/walker.js
+++ b/_source/core/dom/walker.js
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
@@ -47,7 +47,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
return ( ( !movingOut || !limitLTR.equals( node ) )
&& ( !blockerLTR || !node.equals( blockerLTR ) )
- && ( node.type != CKEDITOR.NODE_ELEMENT || node.getName() != 'body' ) );
+ && ( node.type != CKEDITOR.NODE_ELEMENT || !movingOut || node.getName() != 'body' ) );
};
}
@@ -62,7 +62,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
return ( ( !movingOut || !limitRTL.equals( node ) )
&& ( !blockerRTL || !node.equals( blockerRTL ) )
- && ( node.type != CKEDITOR.NODE_ELEMENT || node.getName() != 'body' ) );
+ && ( node.type != CKEDITOR.NODE_ELEMENT || !movingOut || node.getName() != 'body' ) );
};
}
@@ -78,7 +78,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
if ( stopGuard( node, movingOut ) === false )
return false;
- return userGuard( node );
+ return userGuard( node, movingOut );
};
}
else
@@ -101,7 +101,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
node = null;
}
else
- node = ( guard ( node ) === false ) ?
+ node = ( guard ( node, true ) === false ) ?
null : node.getPreviousSourceNode( true, type, guard );
}
else
@@ -115,7 +115,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
node = null;
}
else
- node = ( guard ( range.startContainer ) === false ) ?
+ node = ( guard ( range.startContainer, true ) === false ) ?
null : range.startContainer.getNextSourceNode( true, type, guard ) ;
}
}
@@ -261,7 +261,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
*/
previous : function()
{
- return iterate.call( this, true );
+ return iterate.call( this, 1 );
},
/**
@@ -271,7 +271,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
*/
checkForward : function()
{
- return iterate.call( this, false, true ) !== false;
+ return iterate.call( this, 0, 1 ) !== false;
},
/**
@@ -281,7 +281,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
*/
checkBackward : function()
{
- return iterate.call( this, true, true ) !== false;
+ return iterate.call( this, 1, 1 ) !== false;
},
/**
@@ -303,7 +303,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
*/
lastBackward : function()
{
- return iterateToLast.call( this, true );
+ return iterateToLast.call( this, 1 );
},
reset : function()
@@ -334,16 +334,15 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
'table-column' : 1,
'table-cell' : 1,
'table-caption' : 1
- },
- blockBoundaryNodeNameMatch = { hr : 1 };
+ };
CKEDITOR.dom.element.prototype.isBlockBoundary = function( customNodeNames )
{
- var nodeNameMatches = CKEDITOR.tools.extend( {},
- blockBoundaryNodeNameMatch, customNodeNames || {} );
+ var nodeNameMatches = CKEDITOR.tools.extend( {}, CKEDITOR.dtd.$block, customNodeNames || {} );
- return blockBoundaryDisplayMatch[ this.getComputedStyle( 'display' ) ] ||
- nodeNameMatches[ this.getName() ];
+ // Don't consider floated formatting as block boundary, fall back to dtd check in that case. (#6297)
+ return this.getComputedStyle( 'float' ) == 'none' && blockBoundaryDisplayMatch[ this.getComputedStyle( 'display' ) ]
+ || nodeNameMatches[ this.getName() ];
};
CKEDITOR.dom.walker.blockBoundary = function( customNodeNames )
@@ -359,12 +358,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
return this.blockBoundary( { br : 1 } );
};
- /**
- * Whether the node is a bookmark node's inner text node.
- */
- CKEDITOR.dom.walker.bookmarkContents = function( node )
- {
- },
/**
* Whether the to-be-evaluated node is a bookmark node OR bookmark node
@@ -380,7 +373,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
return ( node && node.getName
&& node.getName() == 'span'
- && node.hasAttribute('_fck_bookmark') );
+ && node.hasAttribute( '_cke_bookmark' ) );
}
return function( node )
@@ -391,12 +384,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
&& isBookmarkNode( parent ) );
// Is bookmark node?
isBookmark = contentOnly ? isBookmark : isBookmark || isBookmarkNode( node );
- return isReject ^ isBookmark;
+ return !! ( isReject ^ isBookmark );
};
};
/**
- * Whether the node contains only white-spaces characters.
+ * Whether the node is a text node containing only whitespaces characters.
* @param isReject
*/
CKEDITOR.dom.walker.whitespaces = function( isReject )
@@ -405,7 +398,47 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
var isWhitespace = node && ( node.type == CKEDITOR.NODE_TEXT )
&& !CKEDITOR.tools.trim( node.getText() );
- return isReject ^ isWhitespace;
+ return !! ( isReject ^ isWhitespace );
+ };
+ };
+
+ /**
+ * Whether the node is invisible in wysiwyg mode.
+ * @param isReject
+ */
+ CKEDITOR.dom.walker.invisible = function( isReject )
+ {
+ var whitespace = CKEDITOR.dom.walker.whitespaces();
+ return function( node )
+ {
+ // Nodes that take no spaces in wysiwyg:
+ // 1. White-spaces but not including NBSP;
+ // 2. Empty inline elements, e.g. we're checking here
+ // 'offsetHeight' instead of 'offsetWidth' for properly excluding
+ // all sorts of empty paragraph, e.g.
.
+ var isInvisible = whitespace( node ) || node.is && !node.$.offsetHeight;
+ return !! ( isReject ^ isInvisible );
};
};
+
+ var tailNbspRegex = /^[\t\r\n ]*(?: |\xa0)$/,
+ isNotWhitespaces = CKEDITOR.dom.walker.whitespaces( 1 ),
+ isNotBookmark = CKEDITOR.dom.walker.bookmark( 0, 1 ),
+ fillerEvaluator = function( element )
+ {
+ return isNotBookmark( element ) && isNotWhitespaces( element );
+ };
+
+ // Check if there's a filler node at the end of an element, and return it.
+ CKEDITOR.dom.element.prototype.getBogus = function()
+ {
+ var tail = this.getLast( fillerEvaluator );
+ if ( tail && ( !CKEDITOR.env.ie ? tail.is && tail.is( 'br' )
+ : tail.getText && tailNbspRegex.test( tail.getText() ) ) )
+ {
+ return tail;
+ }
+ return false;
+ };
+
})();