X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fcore%2Fdom%2Felement.js;h=7adb189839645c3d3a3ceecaba95a16ed7247953;hp=5df3d1987083a3e24d7786bc126b122b44da8307;hb=e73319a12b56100b29ef456fd74114fe5519e01c;hpb=f0610347140239143439a511ee2bd48cb784f470 diff --git a/_source/core/dom/element.js b/_source/core/dom/element.js index 5df3d19..7adb189 100644 --- a/_source/core/dom/element.js +++ b/_source/core/dom/element.js @@ -719,20 +719,31 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype, return false; }, - isEditable : function() + /** + * Decide whether one element is able to receive cursor. + * @param {Boolean} [textCursor=true] Only consider element that could receive text child. + */ + isEditable : function( textCursor ) { - if ( this.isReadOnly() ) - return false; - - // Get the element name. var name = this.getName(); - // Get the element DTD (defaults to span for unknown elements). - var dtd = !CKEDITOR.dtd.$nonEditable[ name ] - && ( CKEDITOR.dtd[ name ] || CKEDITOR.dtd.span ); + if ( this.isReadOnly() + || this.getComputedStyle( 'display' ) == 'none' + || this.getComputedStyle( 'visibility' ) == 'hidden' + || CKEDITOR.dtd.$nonEditable[ name ] ) + { + return false; + } - // In the DTD # == text node. - return ( dtd && dtd['#'] ); + if ( textCursor !== false ) + { + // Get the element DTD (defaults to span for unknown elements). + var dtd = CKEDITOR.dtd[ name ] || CKEDITOR.dtd.span; + // In the DTD # == text node. + return ( dtd && dtd[ '#'] ); + } + + return true; }, isIdentical : function( otherElement ) @@ -781,7 +792,7 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype, */ isVisible : function() { - var isVisible = !!this.$.offsetHeight && this.getComputedStyle( 'visibility' ) != 'hidden', + var isVisible = ( this.$.offsetHeight || this.$.offsetWidth ) && this.getComputedStyle( 'visibility' ) != 'hidden', elementWindow, elementWindowFrame; @@ -798,7 +809,7 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype, } } - return isVisible; + return !!isVisible; }, /** @@ -1288,10 +1299,9 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype, getDocumentPosition : function( refDocument ) { var x = 0, y = 0, - body = this.getDocument().getBody(), - quirks = this.getDocument().$.compatMode == 'BackCompat'; - - var doc = this.getDocument(); + doc = this.getDocument(), + body = doc.getBody(), + quirks = doc.$.compatMode == 'BackCompat'; if ( document.documentElement[ "getBoundingClientRect" ] ) {