X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Fdom%2Fnode.js;h=02a726c5e08de168937ee694432c92f4758c66f8;hb=e371ddf8abcb89013e20e6d0dd746adec344d0e5;hp=30df0a192a85dcef2249d97514c93eee1d0a33e4;hpb=ea7e3453c7b0f023b050aca6d9f83ab372860d91;p=ckeditor.git diff --git a/_source/core/dom/node.js b/_source/core/dom/node.js index 30df0a1..02a726c 100644 --- a/_source/core/dom/node.js +++ b/_source/core/dom/node.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 */ @@ -25,6 +25,10 @@ CKEDITOR.dom.node = function( domNode ) { switch ( domNode.nodeType ) { + // Safari don't consider document as element node type. (#3389) + case CKEDITOR.NODE_DOCUMENT : + return new CKEDITOR.dom.document( domNode ); + case CKEDITOR.NODE_ELEMENT : return new CKEDITOR.dom.element( domNode ); @@ -49,6 +53,13 @@ CKEDITOR.dom.node.prototype = new CKEDITOR.dom.domObject(); CKEDITOR.NODE_ELEMENT = 1; /** + * Document node type. + * @constant + * @example + */ +CKEDITOR.NODE_DOCUMENT = 9; + +/** * Text node type. * @constant * @example @@ -194,27 +205,30 @@ CKEDITOR.tools.extend( CKEDITOR.dom.node.prototype, var parentNode = node.parentNode; var currentIndex = -1; - for ( var i = 0 ; i < parentNode.childNodes.length ; i++ ) + if ( parentNode ) { - var candidate = parentNode.childNodes[i]; - - if ( normalized && - candidate.nodeType == 3 && - candidate.previousSibling && - candidate.previousSibling.nodeType == 3 ) + for ( var i = 0 ; i < parentNode.childNodes.length ; i++ ) { - continue; - } + var candidate = parentNode.childNodes[i]; - currentIndex++; + if ( normalized && + candidate.nodeType == 3 && + candidate.previousSibling && + candidate.previousSibling.nodeType == 3 ) + { + continue; + } - if ( candidate == node ) - break; - } + currentIndex++; + + if ( candidate == node ) + break; + } - address.unshift( currentIndex ); + address.unshift( currentIndex ); + } - node = node.parentNode; + node = parentNode; } return address; @@ -232,7 +246,6 @@ CKEDITOR.tools.extend( CKEDITOR.dom.node.prototype, var document = new CKEDITOR.dom.document( this.$.ownerDocument || this.$.parentNode.ownerDocument ); return ( - /** @ignore */ this.getDocument = function() { return document; @@ -644,6 +657,27 @@ CKEDITOR.tools.extend( CKEDITOR.dom.node.prototype, child.parentNode.removeChild( child ) ; } } + }, + + isReadOnly : function() + { + var current = this; + while( current ) + { + if ( current.type == CKEDITOR.NODE_ELEMENT ) + { + if ( current.is( 'body' ) || current.getCustomData( '_cke_notReadOnly' ) ) + break; + + if ( current.getAttribute( 'contentEditable' ) == 'false' ) + return current; + else if ( current.getAttribute( 'contentEditable' ) == 'true' ) + break; + } + current = current.getParent(); + } + + return false; } } );