/*\r
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
* @param {CKEDITOR.dom.element} parent The anscestor element to get broken.\r
* @example\r
* // Before breaking:\r
- * // <b>This <i>is some<span /> sample</i> test text</b>\r
- * // If "element" is <span /> and "parent" is <i>:\r
- * // <b>This <i>is some</i><span /><i> sample</i> test text</b>\r
+ * // <b>This <i>is some<span /> sample</i> test text</b>\r
+ * // If "element" is <span /> and "parent" is <i>:\r
+ * // <b>This <i>is some</i><span /><i> sample</i> test text</b>\r
* element.breakParent( parent );\r
* @example\r
* // Before breaking:\r
- * // <b>This <i>is some<span /> sample</i> test text</b>\r
- * // If "element" is <span /> and "parent" is <b>:\r
- * // <b>This <i>is some</i></b><span /><b><i> sample</i> test text</b>\r
+ * // <b>This <i>is some<span /> sample</i> test text</b>\r
+ * // If "element" is <span /> and "parent" is <b>:\r
+ * // <b>This <i>is some</i></b><span /><b><i> sample</i> test text</b>\r
* element.breakParent( parent );\r
*/\r
breakParent : function( parent )\r
*/\r
getHtml : function()\r
{\r
- return this.$.innerHTML;\r
+ var retval = this.$.innerHTML;\r
+ // Strip <?xml:namespace> tags in IE. (#3341).\r
+ return CKEDITOR.env.ie ? retval.replace( /<\?[^>]*>/g, '' ) : retval;\r
},\r
\r
getOuterHtml : function()\r
break;\r
\r
case 'checked':\r
- return this.$.checked;\r
- break;\r
+ {\r
+ var attr = this.$.attributes.getNamedItem( name ),\r
+ attrValue = attr.specified ? attr.nodeValue // For value given by parser.\r
+ : this.$.checked; // For value created via DOM interface.\r
+\r
+ return attrValue ? 'checked' : null;\r
+ }\r
+\r
+ case 'hspace':\r
+ return this.$.hspace;\r
\r
case 'style':\r
// IE does not return inline styles via getAttribute(). See #2947.\r
\r
/**\r
* Gets the first child node of this element.\r
+ * @param {Function} evaluator Filtering the result node.\r
* @returns {CKEDITOR.dom.node} The first child node or null if not\r
* available.\r
* @example\r
* var first = <b>element.getFirst()</b>;\r
* alert( first.getName() ); // "b"\r
*/\r
- getFirst : function()\r
+ getFirst : function( evaluator )\r
{\r
- var $ = this.$.firstChild;\r
- return $ ? new CKEDITOR.dom.node( $ ) : null;\r
+ var first = this.$.firstChild,\r
+ retval = first && new CKEDITOR.dom.node( first );\r
+ if ( retval && evaluator && !evaluator( retval ) )\r
+ retval = retval.getNext( evaluator );\r
+\r
+ return retval;\r
},\r
\r
/**\r
for ( i = 0 ; i < otherLength ; i++ )\r
{\r
attribute = otherAttribs[ i ];\r
-\r
- if ( ( !CKEDITOR.env.ie || ( attribute.specified && attribute.nodeName != '_cke_expando' ) ) && attribute.nodeValue != thisAttribs.getAttribute( attribute.nodeName ) )\r
+ if ( attribute.specified && attribute.nodeName != '_cke_expando'\r
+ && attribute.nodeValue != this.getAttribute( attribute.nodeName ) )\r
return false;\r
}\r
}\r
*/\r
isVisible : function()\r
{\r
- return this.$.offsetWidth && ( this.$.style.visibility != 'hidden' );\r
+ var isVisible = !!this.$.offsetHeight && this.getComputedStyle( 'visibility' ) != 'hidden',\r
+ elementWindow,\r
+ elementWindowFrame;\r
+\r
+ // Webkit and Opera report non-zero offsetHeight despite that\r
+ // element is inside an invisible iframe. (#4542)\r
+ if ( isVisible && ( CKEDITOR.env.webkit || CKEDITOR.env.opera ) )\r
+ {\r
+ elementWindow = this.getWindow();\r
+\r
+ if ( !elementWindow.equals( CKEDITOR.document.getWindow() )\r
+ && ( elementWindowFrame = elementWindow.$.frameElement ) )\r
+ {\r
+ isVisible = new CKEDITOR.dom.element( elementWindowFrame ).isVisible();\r
+ }\r
+ }\r
+\r
+ return isVisible;\r
},\r
\r
/**\r
*/\r
removeStyle : function( name )\r
{\r
+ this.setStyle( name, '' );\r
if ( this.$.style.removeAttribute )\r
this.$.style.removeAttribute( CKEDITOR.tools.cssStyleToDomStyle( name ) );\r
- else\r
- this.setStyle( name, '' );\r
\r
if ( !this.$.style.cssText )\r
this.removeAttribute( 'style' );\r
{\r
var attribute = attributes[n];\r
\r
+ // Lowercase attribute name hard rule is broken for\r
+ // some attribute on IE, e.g. CHECKED.\r
+ var attrName = attribute.nodeName.toLowerCase(),\r
+ attrValue;\r
+\r
+ // We can set the type only once, so do it with the proper value, not copying it.\r
+ if ( attrName in skipAttributes )\r
+ continue;\r
+\r
+ if( attrName == 'checked' && ( attrValue = this.getAttribute( attrName ) ) )\r
+ dest.setAttribute( attrName, attrValue );\r
// IE BUG: value attribute is never specified even if it exists.\r
- if ( attribute.specified ||\r
- ( CKEDITOR.env.ie && attribute.nodeValue && attribute.nodeName.toLowerCase() == 'value' ) )\r
+ else if ( attribute.specified ||\r
+ ( CKEDITOR.env.ie && attribute.nodeValue && attrName == 'value' ) )\r
{\r
- var attrName = attribute.nodeName;\r
- // We can set the type only once, so do it with the proper value, not copying it.\r
- if ( attrName in skipAttributes )\r
- continue;\r
-\r
- var attrValue = this.getAttribute( attrName );\r
+ attrValue = this.getAttribute( attrName );\r
if ( attrValue === null )\r
attrValue = attribute.nodeValue;\r
\r