X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Fdom%2Fdocument.js;h=1435fbdd627fd7c043a6ad5a5cecff0bebb760ba;hb=9afde8772159bd3436f1f5b7862960307710ae5a;hp=dd0f9a0f9b57aa3ad96aeb9b087a17af36e5b0d2;hpb=ea7e3453c7b0f023b050aca6d9f83ab372860d91;p=ckeditor.git diff --git a/_source/core/dom/document.js b/_source/core/dom/document.js index dd0f9a0..1435fbd 100644 --- a/_source/core/dom/document.js +++ b/_source/core/dom/document.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 */ @@ -52,6 +52,21 @@ CKEDITOR.tools.extend( CKEDITOR.dom.document.prototype, } }, + appendStyleText : function( cssStyleText ) + { + if ( this.$.createStyleSheet ) + { + var styleSheet = this.$.createStyleSheet( "" ); + styleSheet.cssText = cssStyleText ; + } + else + { + var style = new CKEDITOR.dom.element( 'style', this ); + style.append( new CKEDITOR.dom.text( cssStyleText, this ) ); + this.getHead().append( style ); + } + }, + createElement : function( name, attribsAndStyles ) { var element = new CKEDITOR.dom.element( name, this ); @@ -135,7 +150,7 @@ CKEDITOR.tools.extend( CKEDITOR.dom.document.prototype, getElementsByTag : function( tagName, namespace ) { - if ( !CKEDITOR.env.ie && namespace ) + if ( !( CKEDITOR.env.ie && ! ( document.documentMode > 8 ) ) && namespace ) tagName = namespace + ':' + tagName; return new CKEDITOR.dom.nodeList( this.$.getElementsByTagName( tagName ) ); }, @@ -150,10 +165,12 @@ CKEDITOR.tools.extend( CKEDITOR.dom.document.prototype, getHead : function() { var head = this.$.getElementsByTagName( 'head' )[0]; + if ( !head ) + head = this.getDocumentElement().append( new CKEDITOR.dom.element( 'head' ), true ); + else head = new CKEDITOR.dom.element( head ); return ( - /** @ignore */ this.getHead = function() { return head; @@ -172,19 +189,21 @@ CKEDITOR.tools.extend( CKEDITOR.dom.document.prototype, var body = new CKEDITOR.dom.element( this.$.body ); return ( - /** @ignore */ this.getBody = function() { return body; })(); }, + /** + * Gets the DOM document element for this document. + * @returns {CKEDITOR.dom.element} The DOM document element. + */ getDocumentElement : function() { var documentElement = new CKEDITOR.dom.element( this.$.documentElement ); return ( - /** @ignore */ this.getDocumentElement = function() { return documentElement; @@ -194,17 +213,39 @@ CKEDITOR.tools.extend( CKEDITOR.dom.document.prototype, /** * Gets the window object that holds this document. * @returns {CKEDITOR.dom.window} The window object. - * @example */ getWindow : function() { var win = new CKEDITOR.dom.window( this.$.parentWindow || this.$.defaultView ); return ( - /** @ignore */ this.getWindow = function() { return win; })(); + }, + + /** + * Defines the document contents through document.write. Note that the + * previous document contents will be lost (cleaned). + * @since 3.5 + * @param {String} html The HTML defining the document contents. + * @example + * document.write( + * '<html>' + + * '<head><title>Sample Doc</title></head>' + + * '<body>Document contents created by code</body>' + + * '</html>' ); + */ + write : function( html ) + { + // Don't leave any history log in IE. (#5657) + this.$.open( 'text/html', 'replace' ); + + // Support for custom document.domain in IE. + CKEDITOR.env.isCustomDomain() && ( this.$.domain = document.domain ); + + this.$.write( html ); + this.$.close(); } });