X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Fdom%2Fwalker.js;h=7f430b8ad026c1a4ddf66ef0bbcdcf3e7401190f;hb=refs%2Ftags%2Fv3.6.2;hp=ae9dfec31e1dcda5df1218ea0966a727c608ae70;hpb=039a051ccf3901311661022a30afd60fc38130c9;p=ckeditor.git diff --git a/_source/core/dom/walker.js b/_source/core/dom/walker.js index ae9dfec..7f430b8 100644 --- a/_source/core/dom/walker.js +++ b/_source/core/dom/walker.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -334,16 +334,17 @@ 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 = customNodeNames ? + CKEDITOR.tools.extend( {}, CKEDITOR.dtd.$block, customNodeNames || {} ) : + CKEDITOR.dtd.$block; - 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 ) @@ -374,7 +375,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { return ( node && node.getName && node.getName() == 'span' - && node.hasAttribute( '_cke_bookmark' ) ); + && node.data( 'cke-bookmark' ) ); } return function( node ) @@ -422,18 +423,34 @@ For licensing, see LICENSE.html or http://ckeditor.com/license }; }; + CKEDITOR.dom.walker.nodeType = function( type, isReject ) + { + return function( node ) + { + return !! ( isReject ^ ( node.type == type ) ); + }; + }; + var tailNbspRegex = /^[\t\r\n ]*(?: |\xa0)$/, - isNotWhitespaces = CKEDITOR.dom.walker.whitespaces( 1 ), - isNotBookmark = CKEDITOR.dom.walker.bookmark( 0, 1 ), - fillerEvaluator = function( element ) + isWhitespaces = CKEDITOR.dom.walker.whitespaces(), + isBookmark = CKEDITOR.dom.walker.bookmark(), + toSkip = function( node ) { - return isNotBookmark( element ) && isNotWhitespaces( element ); + return isBookmark( node ) + || isWhitespaces( node ) + || node.type == CKEDITOR.NODE_ELEMENT + && node.getName() in CKEDITOR.dtd.$inline + && !( node.getName() in CKEDITOR.dtd.$empty ); }; // 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 ); + // Bogus are not always at the end, e.g.

text

(#7070). + var tail = this; + do { tail = tail.getPreviousSourceNode(); } + while ( toSkip( tail ) ) + if ( tail && ( !CKEDITOR.env.ie ? tail.is && tail.is( 'br' ) : tail.getText && tailNbspRegex.test( tail.getText() ) ) ) {