Index: /CKEditor/branches/features/adobeair/_source/core/dom/document.js
===================================================================
--- /CKEditor/branches/features/adobeair/_source/core/dom/document.js	(revision 6147)
+++ /CKEditor/branches/features/adobeair/_source/core/dom/document.js	(revision 6148)
@@ -227,79 +227,25 @@
 
 		/**
-		 * Wrapper for document.write that works around certain security
-		 * limitation because of the closed stream when calling this method.
-		 * @param html
-		 * @param mode
-		 */
-		write : function( html, mode )
-		{
-			// document.write() or document.writeln() fail silently after
-			// the page load event in Adobe AIR.
-			// DOM manipulation could be used instead.
-			if ( CKEDITOR.env.air && this.getBody() )
-			{
-				// We're taking the below extra work only because innerHTML
-				// on <html> element doesn't work as expected.
-				var doc = this;
-
-				// Grab all the <link> and <style>.
-				var styleSheetLinks = [],
-						styleTexts = [];
-
-				html.replace( /<style[^>]*>([\s\S]*?)<\/style>/gi, function ( match, styleText )
-				{
-					styleTexts.push( styleText );
-				});
-
-				html.replace( /<link[^>]*?>/gi, function( linkHtml )
-				{
-					styleSheetLinks.push( linkHtml );
-				});
-
-				if ( styleSheetLinks.length )
-				{
-					// Inject the <head> HTML inside a <div>.
-					// Do that before getDocumentHead because WebKit moves
-					// <link css> elements to the <head> at this point.
-					var div = new CKEDITOR.dom.element( 'div', doc );
-					div.setHtml( styleSheetLinks.join( '' ) );
-					// Move the <div> nodes to <head>.
-					div.moveChildren( this.getHead( doc ) );
-				}
-
-				// Create style nodes for inline css.
-				// ( <style> content doesn't applied when setting via innerHTML )
-				var count = styleTexts.length;
-				if ( count )
-				{
-					var head = this.getHead( doc );
-					for ( var i = 0; i < count; i++ )
-					{
-						var node = head.append( 'style' );
-						node.setAttribute( "type", "text/css" );
-						node.append( doc.createText( styleTexts[ i ] ) );
-					}
-				}
-			
-				// Copy the entire <body>.  
-				doc.getBody().setAttributes( CKEDITOR.htmlParser.fragment.fromHtml(
-					// Separate body content and attributes.
-					html.replace( /(<body[^>]*>)([\s\S]*)(?=<\/body>)/i,
-						function( match, startTag, innerHTML )
-						{
-							doc.getBody().setHtml( innerHTML );
-							return startTag;
-						})
-					).children[ 0 ].attributes );
-			}
-			else
-			{
-				this.$.open( "text/html", mode );
-				// Support for custom document.domain in IE.
-				if ( CKEDITOR.env.isCustomDomain() )
-					this.$.domain = document.domain;
-				this.$.write( html );
-				this.$.close();
-			}
+		 * 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(
+		 *     '&lt;html&gt;' +
+		 *         '&lt;head&gt;&lt;title&gt;Sample Doc&lt;/title&gt;&lt;/head&gt;' +
+		 *         '&lt;body&gt;Document contents created by code&lt;/body&gt;' +
+		 *      '&lt;/html&gt;' );
+		 */
+		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();
 		}
 	});
Index: /CKEditor/branches/features/adobeair/_source/plugins/adobeair/plugin.js
===================================================================
--- /CKEditor/branches/features/adobeair/_source/plugins/adobeair/plugin.js	(revision 6147)
+++ /CKEditor/branches/features/adobeair/_source/plugins/adobeair/plugin.js	(revision 6148)
@@ -7,5 +7,6 @@
 {
 	var eventNameList = [ 'click', 'keydown', 'mousedown', 'keypress' ];
-	// any inline event callbacks assigned via innerHTML/outerHTML such as
+
+	// Inline event callbacks assigned via innerHTML/outerHTML, such as
 	// onclick/onmouseover, are ignored in AIR.
 	// Use DOM2 event listeners to substitue inline handlers instead.
@@ -16,4 +17,5 @@
 			count = children.count(),
 			child;
+
 		for ( var i = 0; i < count; i++ )
 		{
@@ -102,5 +104,4 @@
 			editor._.air_bootstrap_frame_url = this.path + '/assets/air_boostrap_frame.html?' + editor.name;
 
-
 			editor.on( 'uiReady', function()
 				{
@@ -111,4 +112,13 @@
 				});
 
+			editor.on( 'contentDom', function()
+				{
+					// Hyperlinks are enabled in editable documents in Adobe
+					// AIR. Prevent their click behavior.
+					editor.document.on( 'click', function( ev )
+						{
+							ev.data.preventDefault( true );
+						});
+				});
 		},
 
@@ -143,2 +153,71 @@
 	});
 })();
+
+CKEDITOR.dom.document.prototype.write = CKEDITOR.tools.override( CKEDITOR.dom.document.prototype.write,
+	function( original_write )
+	{
+		return function( html, mode )
+			{
+				// document.write() or document.writeln() fail silently after
+				// the page load event in Adobe AIR.
+				// DOM manipulation could be used instead.
+				if ( this.getBody() )
+				{
+					// We're taking the below extra work only because innerHTML
+					// on <html> element doesn't work as expected.
+					var doc = this;
+
+					// Grab all the <link> and <style>.
+					var styleSheetLinks = [],
+							styleTexts = [];
+
+					html.replace( /<style[^>]*>([\s\S]*?)<\/style>/gi, function ( match, styleText )
+					{
+						styleTexts.push( styleText );
+					});
+
+					html.replace( /<link[^>]*?>/gi, function( linkHtml )
+					{
+						styleSheetLinks.push( linkHtml );
+					});
+
+					if ( styleSheetLinks.length )
+					{
+						// Inject the <head> HTML inside a <div>.
+						// Do that before getDocumentHead because WebKit moves
+						// <link css> elements to the <head> at this point.
+						var div = new CKEDITOR.dom.element( 'div', doc );
+						div.setHtml( styleSheetLinks.join( '' ) );
+						// Move the <div> nodes to <head>.
+						div.moveChildren( this.getHead( doc ) );
+					}
+
+					// Create style nodes for inline css.
+					// ( <style> content doesn't applied when setting via innerHTML )
+					var count = styleTexts.length;
+					if ( count )
+					{
+						var head = this.getHead( doc );
+						for ( var i = 0; i < count; i++ )
+						{
+							var node = head.append( 'style' );
+							node.setAttribute( "type", "text/css" );
+							node.append( doc.createText( styleTexts[ i ] ) );
+						}
+					}
+			
+					// Copy the entire <body>.  
+					doc.getBody().setAttributes( CKEDITOR.htmlParser.fragment.fromHtml(
+						// Separate body content and attributes.
+						html.replace( /(<body[^>]*>)([\s\S]*)(?=<\/body>)/i,
+							function( match, startTag, innerHTML )
+							{
+								doc.getBody().setHtml( innerHTML );
+								return startTag;
+							})
+						).children[ 0 ].attributes );
+				}
+				else
+					original_write.apply( this, arguments );
+			};
+	});
Index: /CKEditor/branches/features/adobeair/_source/plugins/wysiwygarea/plugin.js
===================================================================
--- /CKEditor/branches/features/adobeair/_source/plugins/wysiwygarea/plugin.js	(revision 6147)
+++ /CKEditor/branches/features/adobeair/_source/plugins/wysiwygarea/plugin.js	(revision 6148)
@@ -608,15 +608,4 @@
 						}
 
-						if ( CKEDITOR.env.air )
-						{
-							// Hyperlinks is enabled in Adobe AIR wysiwyg mode.   
-							domDocument.$.addEventListener( 'click', function( ev )
-								{
-									ev.preventDefault() ;
-									ev.stopPropagation() ;
-								}, true ) ;
-						}
-						var focusTarget = ( CKEDITOR.env.ie || CKEDITOR.env.webkit ) ?
-								domWindow : domDocument;
 						// IE standard compliant in editing frame doesn't focus the editor when
 						// clicking outside actual content, manually apply the focus. (#1659)
@@ -974,5 +963,5 @@
 								else if ( !CKEDITOR.env.opera && win )
 								{
-									// AIR need a while when focus was switching previously  from a link.
+									// AIR needs a while to focus when moving from a link.
 									CKEDITOR.env.air ? setTimeout( function () { win.focus(); }, 0 ) : win.focus();
 									editor.selectionChange();
