JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.2
[ckeditor.git] / _source / core / dom / element.js
index 6e6a42c..7adb189 100644 (file)
@@ -719,20 +719,31 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
                        return false;\r
                },\r
 \r
-               isEditable : function()\r
+               /**\r
+                * Decide whether one element is able to receive cursor.\r
+                * @param {Boolean} [textCursor=true] Only consider element that could receive text child.\r
+                */\r
+               isEditable : function( textCursor )\r
                {\r
-                       if ( this.isReadOnly() )\r
-                               return false;\r
-\r
-                       // Get the element name.\r
                        var name = this.getName();\r
 \r
-                       // Get the element DTD (defaults to span for unknown elements).\r
-                       var dtd = !CKEDITOR.dtd.$nonEditable[ name ]\r
-                                               && ( CKEDITOR.dtd[ name ] || CKEDITOR.dtd.span );\r
+                       if ( this.isReadOnly()\r
+                                       || this.getComputedStyle( 'display' ) == 'none'\r
+                                       || this.getComputedStyle( 'visibility' ) == 'hidden'\r
+                                       || CKEDITOR.dtd.$nonEditable[ name ] )\r
+                       {\r
+                               return false;\r
+                       }\r
 \r
-                       // In the DTD # == text node.\r
-                       return ( dtd && dtd['#'] );\r
+                       if ( textCursor !== false )\r
+                       {\r
+                               // Get the element DTD (defaults to span for unknown elements).\r
+                               var dtd = CKEDITOR.dtd[ name ] || CKEDITOR.dtd.span;\r
+                               // In the DTD # == text node.\r
+                               return ( dtd && dtd[ '#'] );\r
+                       }\r
+\r
+                       return true;\r
                },\r
 \r
                isIdentical : function( otherElement )\r
@@ -781,7 +792,7 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
                 */\r
                isVisible : function()\r
                {\r
-                       var isVisible = !!this.$.offsetHeight && this.getComputedStyle( 'visibility' ) != 'hidden',\r
+                       var isVisible = ( this.$.offsetHeight || this.$.offsetWidth ) && this.getComputedStyle( 'visibility' ) != 'hidden',\r
                                elementWindow,\r
                                elementWindowFrame;\r
 \r
@@ -798,7 +809,7 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
                                }\r
                        }\r
 \r
-                       return isVisible;\r
+                       return !!isVisible;\r
                },\r
 \r
                /**\r
@@ -1062,6 +1073,18 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
                                        return this;\r
                                };\r
                        }\r
+                       else if ( CKEDITOR.env.ie8Compat && CKEDITOR.env.secure )\r
+                       {\r
+                               return function( name, value )\r
+                               {\r
+                                       // IE8 throws error when setting src attribute to non-ssl value. (#7847)\r
+                                       if ( name == 'src' && value.match( /^http:\/\// ) )\r
+                                               try { standard.apply( this, arguments ); } catch( e ){}\r
+                                       else\r
+                                               standard.apply( this, arguments );\r
+                                       return this;\r
+                               };\r
+                       }\r
                        else\r
                                return standard;\r
                })(),\r
@@ -1276,10 +1299,9 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
                getDocumentPosition : function( refDocument )\r
                {\r
                        var x = 0, y = 0,\r
-                               body = this.getDocument().getBody(),\r
-                               quirks = this.getDocument().$.compatMode == 'BackCompat';\r
-\r
-                       var doc = this.getDocument();\r
+                               doc = this.getDocument(),\r
+                               body = doc.getBody(),\r
+                               quirks = doc.$.compatMode == 'BackCompat';\r
 \r
                        if ( document.documentElement[ "getBoundingClientRect" ] )\r
                        {\r
@@ -1583,7 +1605,13 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
                 */\r
                getDirection : function( useComputed )\r
                {\r
-                       return useComputed ? this.getComputedStyle( 'direction' ) : this.getStyle( 'direction' ) || this.getAttribute( 'dir' );\r
+                       return useComputed ?\r
+                               this.getComputedStyle( 'direction' )\r
+                                       // Webkit: offline element returns empty direction (#8053).\r
+                                       || this.getDirection()\r
+                                       || this.getDocument().$.dir\r
+                                       || this.getDocument().getBody().getDirection( 1 )\r
+                               : this.getStyle( 'direction' ) || this.getAttribute( 'dir' );\r
                },\r
 \r
                /**\r