JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.6.1
[ckeditor.git] / _source / core / dom / element.js
index c83674a..bb315a4 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -105,6 +105,9 @@ CKEDITOR.dom.element.clearMarkers = function( database, element, removeFromDatab
        }\r
 };\r
 \r
+( function()\r
+{\r
+\r
 CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,\r
        /** @lends CKEDITOR.dom.element.prototype */\r
        {\r
@@ -466,6 +469,11 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
                                                case 'style':\r
                                                        // IE does not return inline styles via getAttribute(). See #2947.\r
                                                        return this.$.style.cssText;\r
+\r
+                                               case 'contenteditable':\r
+                                               case 'contentEditable':\r
+                                                       return this.$.attributes.getNamedItem( 'contentEditable' ).specified ?\r
+                                                                       this.$.getAttribute( 'contentEditable' ) : null;\r
                                        }\r
 \r
                                        return standard.call( this, name );\r
@@ -499,7 +507,10 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
                        :\r
                                function( propertyName )\r
                                {\r
-                                       return this.getWindow().$.getComputedStyle( this.$, '' ).getPropertyValue( propertyName );\r
+                                       var style = this.getWindow().$.getComputedStyle( this.$, null );\r
+\r
+                                       // Firefox may return null if we call the above on a hidden iframe. (#9117)\r
+                                       return style ? style.getPropertyValue( propertyName ) : '';\r
                                },\r
 \r
                /**\r
@@ -731,7 +742,8 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
                                        || this.getComputedStyle( 'display' ) == 'none'\r
                                        || this.getComputedStyle( 'visibility' ) == 'hidden'\r
                                        || this.is( 'a' ) && this.data( 'cke-saved-name' ) && !this.getChildCount()\r
-                                       || CKEDITOR.dtd.$nonEditable[ name ] )\r
+                                       || CKEDITOR.dtd.$nonEditable[ name ]\r
+                                       || CKEDITOR.dtd.$empty[ name ] )\r
                        {\r
                                return false;\r
                        }\r
@@ -1069,6 +1081,8 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
                                                this.$.tabIndex = value;\r
                                        else if ( name == 'checked' )\r
                                                this.$.checked = value;\r
+                                       else if ( name == 'contenteditable' )\r
+                                               standard.call( this, 'contentEditable', value );\r
                                        else\r
                                                standard.apply( this, arguments );\r
                                        return this;\r
@@ -1143,6 +1157,8 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
                                                name = 'className';\r
                                        else if ( name == 'tabindex' )\r
                                                name = 'tabIndex';\r
+                                       else if ( name == 'contenteditable' )\r
+                                               name = 'contentEditable';\r
                                        standard.call( this, name );\r
                                };\r
                        }\r
@@ -1174,9 +1190,19 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
                 */\r
                removeStyle : function( name )\r
                {\r
-                       this.setStyle( name, '' );\r
-                       if ( this.$.style.removeAttribute )\r
-                               this.$.style.removeAttribute( CKEDITOR.tools.cssStyleToDomStyle( name ) );\r
+                       // Removes the specified property from the current style object.\r
+                       var $ = this.$.style;\r
+\r
+                       // "removeProperty" need to be specific on the following styles.\r
+                       if ( !$.removeProperty && ( name == 'border' || name == 'margin' || name == 'padding' ) )\r
+                       {\r
+                               var names = expandedRules( name );\r
+                               for ( var i = 0 ; i < names.length ; i++ )\r
+                                       this.removeStyle( names[ i ] );\r
+                               return;\r
+                       }\r
+\r
+                       $.removeProperty ? $.removeProperty( name ) : $.removeAttribute( CKEDITOR.tools.cssStyleToDomStyle( name ) );\r
 \r
                        if ( !this.$.style.cssText )\r
                                this.removeAttribute( 'style' );\r
@@ -1227,7 +1253,7 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
                 */\r
                setOpacity : function( opacity )\r
                {\r
-                       if ( CKEDITOR.env.ie )\r
+                       if ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 )\r
                        {\r
                                opacity = Math.round( opacity * 100 );\r
                                this.setStyle( 'filter', opacity >= 100 ? '' : 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + opacity + ')' );\r
@@ -1742,13 +1768,35 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
                }\r
        });\r
 \r
-( function()\r
-{\r
        var sides = {\r
                width : [ "border-left-width", "border-right-width","padding-left", "padding-right" ],\r
                height : [ "border-top-width", "border-bottom-width", "padding-top",  "padding-bottom" ]\r
        };\r
 \r
+       // Generate list of specific style rules, applicable to margin/padding/border.\r
+       function expandedRules( style )\r
+       {\r
+               var sides = [ 'top', 'left', 'right', 'bottom' ], components;\r
+\r
+               if ( style == 'border' )\r
+                               components = [ 'color', 'style', 'width' ];\r
+\r
+               var styles = [];\r
+               for ( var i = 0 ; i < sides.length ; i++ )\r
+               {\r
+\r
+                       if ( components )\r
+                       {\r
+                               for ( var j = 0 ; j < components.length ; j++ )\r
+                                       styles.push( [ style, sides[ i ], components[j] ].join( '-' ) );\r
+                       }\r
+                       else\r
+                               styles.push( [ style, sides[ i ] ].join( '-' ) );\r
+               }\r
+\r
+               return styles;\r
+       }\r
+\r
        function marginAndPaddingSize( type )\r
        {\r
                var adjustment = 0;\r