Index: CKEditor/releases/stable/_source/plugins/wysiwygarea/plugin.js
===================================================================
--- CKEditor/releases/stable/_source/plugins/wysiwygarea/plugin.js	(revision 4887)
+++ CKEditor/releases/stable/_source/plugins/wysiwygarea/plugin.js	(revision 5194)
@@ -90,5 +90,5 @@
 				if ( isBlock )
 				{
-					while( ( current = range.getCommonAncestor( false, true ) )
+					while ( ( current = range.getCommonAncestor( false, true ) )
 							&& ( dtd = CKEDITOR.dtd[ current.getName() ] )
 							&& !( dtd && dtd [ elementName ] ) )
@@ -144,5 +144,5 @@
 	function restoreDirty( editor )
 	{
-		if( !editor.checkDirty() )
+		if ( !editor.checkDirty() )
 			setTimeout( function(){ editor.resetDirty(); } );
 	}
@@ -196,5 +196,5 @@
 			// If the fixed block is blank and already followed by a exitable
 			// block, we should revert the fix. (#3684)
-			if( fixedBlock.getOuterHtml().match( emptyParagraphRegexp ) )
+			if ( fixedBlock.getOuterHtml().match( emptyParagraphRegexp ) )
 			{
 				var previousElement = fixedBlock.getPrevious( isNotWhitespace ),
@@ -215,5 +215,5 @@
 			range.select();
 			// Notify non-IE that selection has changed.
-			if( !CKEDITOR.env.ie )
+			if ( !CKEDITOR.env.ie )
 				editor.selectionChange();
 		}
@@ -226,5 +226,5 @@
 		{
 			restoreDirty( editor );
-			if( !CKEDITOR.env.ie )
+			if ( !CKEDITOR.env.ie )
 				body.appendBogus();
 			else
@@ -242,8 +242,9 @@
 				? editor.config.enterMode == CKEDITOR.ENTER_DIV ? 'div' : 'p' : false;
 
+			var frameLabel = editor.lang.editorTitle.replace( '%1', editor.name );
+
 			editor.on( 'editingBlockReady', function()
 				{
 					var mainElement,
-						fieldset,
 						iframe,
 						isLoadingData,
@@ -252,4 +253,5 @@
 						fireMode;
 
+
 					// Support for custom document.domain in IE.
 					var isCustomDomain = CKEDITOR.env.isCustomDomain();
@@ -260,80 +262,49 @@
 						if ( iframe )
 							iframe.remove();
-						if ( fieldset )
-							fieldset.remove();
 
 						frameLoaded = 0;
+
+						var setDataFn = !CKEDITOR.env.gecko && CKEDITOR.tools.addFunction( function( doc )
+							{
+								CKEDITOR.tools.removeFunction( setDataFn );
+								doc.write( data );
+							});
+
+						var srcScript =
+							'document.open();' +
+
+							// The document domain must be set any time we
+							// call document.open().
+							( isCustomDomain ? ( 'document.domain="' + document.domain + '";' ) : '' ) +
+
+							// With FF, it's better to load the data on
+							// iframe.load. (#3894,#4058)
+							// But in FF, we still need the open()-close() call
+							// to avoid HTTPS warnings.
+							( CKEDITOR.env.gecko ? '' : ( 'parent.CKEDITOR.tools.callFunction(' + setDataFn + ',document);' ) ) +
+
+							'document.close();';
 
 						iframe = CKEDITOR.dom.element.createFromHtml( '<iframe' +
   							' style="width:100%;height:100%"' +
   							' frameBorder="0"' +
-							// Support for custom document.domain in IE.
-							( isCustomDomain ?
-								' src="javascript:void((function(){' +
-									'document.open();' +
-									'document.domain=\'' + document.domain + '\';' +
-									'document.close();' +
-								'})())"' : '' ) +
-  							' tabIndex="-1"' +
+  							' src="javascript:void(function(){' + encodeURIComponent( srcScript ) + '}())"' +
+  							' tabIndex="' + editor.tabIndex + '"' +
   							' allowTransparency="true"' +
   							'></iframe>' );
 
-						// Register onLoad event for iframe element, which
-						// will fill it with content and set custom domain.
-						iframe.on( 'load', function( e )
-						{
-							e.removeListener();
-							var doc = iframe.getFrameDocument().$;
-
-							// Custom domain handling is needed after each document.open().
-							doc.open();
-							if ( isCustomDomain )
-								doc.domain = document.domain;
-							doc.write( data );
-							doc.close();
-
-						} );
-
-						var accTitle = editor.lang.editorTitle.replace( '%1', editor.name );
-
-						if ( CKEDITOR.env.gecko )
-						{
-							// Accessibility attributes for Firefox.
-							mainElement.setAttributes(
-								{
-									role : 'region',
-									title : accTitle
-								} );
-							iframe.setAttributes(
-								{
-									role : 'region',
-									title : ' '
-								} );
-						}
-						else if ( CKEDITOR.env.webkit )
-						{
-							iframe.setAttribute( 'title', accTitle );	// Safari 4
-							iframe.setAttribute( 'name', accTitle );	// Safari 3
-						}
-						else if ( CKEDITOR.env.ie )
-						{
-							// Accessibility label for IE.
-							fieldset = CKEDITOR.dom.element.createFromHtml(
-								'<fieldset style="height:100%' +
-								( CKEDITOR.env.ie && CKEDITOR.env.quirks ? ';position:relative' : '' ) +
-								'">' +
-									'<legend style="display:block;width:0;height:0;overflow:hidden;' +
-									( CKEDITOR.env.ie && CKEDITOR.env.quirks ? 'position:absolute' : '' ) +
-									'">' +
-										CKEDITOR.tools.htmlEncode( accTitle ) +
-									'</legend>' +
-								'</fieldset>'
-								, CKEDITOR.document );
-							iframe.appendTo( fieldset );
-							fieldset.appendTo( mainElement );
-						}
-
-						if ( !CKEDITOR.env.ie )
-							mainElement.append( iframe );
+						// With FF, it's better to load the data on iframe.load. (#3894,#4058)
+						CKEDITOR.env.gecko && iframe.on( 'load', function( ev )
+							{
+								ev.removeListener();
+
+								var doc = iframe.getFrameDocument().$;
+
+								doc.open();
+								doc.write( data );
+								doc.close();
+							});
+
+						mainElement.append( iframe );
 					};
 
@@ -341,6 +312,7 @@
 					// is fully editable even before the editing iframe is fully loaded (#4455).
 					var activationScript =
-						'<script id="cke_actscrpt" type="text/javascript">' +
-							'window.parent.CKEDITOR._["contentDomReady' + editor.name + '"]( window );' +
+						'<script id="cke_actscrpt" type="text/javascript" cke_temp="1">' +
+							( isCustomDomain ? ( 'document.domain="' + document.domain + '";' ) : '' ) +
+							'parent.CKEDITOR._["contentDomReady' + editor.name + '"]( window );' +
 						'</script>';
 
@@ -350,6 +322,7 @@
 						if ( frameLoaded )
 							return;
-
 						frameLoaded = 1;
+
+						editor.fire( 'ariaWidget', iframe );
 
 						var domDocument = domWindow.document,
@@ -417,5 +390,5 @@
 						// IE standard compliant in editing frame doesn't focus the editor when
 						// clicking outside actual content, manually apply the focus. (#1659)
-						if( CKEDITOR.env.ie
+						if ( CKEDITOR.env.ie
 							&& domDocument.$.compatMode == 'CSS1Compat' )
 						{
@@ -446,8 +419,8 @@
 								{
 									var first = body;
-									while( first.firstChild )
+									while ( first.firstChild )
 										first = first.firstChild;
 
-									if( !first.nextSibling
+									if ( !first.nextSibling
 										&& ( 'BR' == first.tagName )
 										&& first.hasAttribute( '_moz_editor_bogus_node' ) )
@@ -476,18 +449,32 @@
 						if ( CKEDITOR.env.ie )
 						{
-							// Cancel default action for backspace in IE on control types. (#4047)
+							// Override keystrokes which should have deletion behavior
+							//  on control types in IE . (#4047)
 							domDocument.on( 'keydown', function( evt )
 							{
-								// Backspace.
-								var control = evt.data.getKeystroke() == 8
-											  && editor.getSelection().getSelectedElement();
-								if ( control )
-								{
-									// Make undo snapshot.
-									editor.fire( 'saveSnapshot' );
-									// Remove manually.
-									control.remove();
-									editor.fire( 'saveSnapshot' );
-									evt.cancel();
+								var keyCode = evt.data.getKeystroke();
+
+								// Backspace OR Delete.
+								if ( keyCode in { 8 : 1, 46 : 1 } )
+								{
+									var sel = editor.getSelection(),
+										control = sel.getSelectedElement();
+
+									if ( control )
+									{
+										// Make undo snapshot.
+										editor.fire( 'saveSnapshot' );
+
+										// Delete any element that 'hasLayout' (e.g. hr,table) in IE8 will
+										// break up the selection, safely manage it here. (#4795)
+										var bookmark = sel.getRanges()[ 0 ].createBookmark();
+										// Remove the control manually.
+										control.remove();
+										sel.selectBookmarks( [ bookmark ] );
+
+										editor.fire( 'saveSnapshot' );
+
+										evt.data.preventDefault();
+									}
 								}
 							} );
@@ -495,10 +482,10 @@
 							// PageUp/PageDown scrolling is broken in document
 							// with standard doctype, manually fix it. (#4736)
-							if( domDocument.$.compatMode == 'CSS1Compat' )
+							if ( domDocument.$.compatMode == 'CSS1Compat' )
 							{
 								var pageUpDownKeys = { 33 : 1, 34 : 1 };
 								domDocument.on( 'keydown', function( evt )
 								{
-									if( evt.data.getKeystroke() in pageUpDownKeys )
+									if ( evt.data.getKeystroke() in pageUpDownKeys )
 									{
 										setTimeout( function ()
@@ -650,4 +637,5 @@
 										config.docType +
 										'<html dir="' + config.contentsLangDirection + '">' +
+										'<title>' + frameLabel + '</title>' +
 										'<head>' +
 											baseTag +
@@ -745,6 +733,17 @@
 				});
 
+			var titleBackup;
+			// Setting voice label as window title, backup the original one
+			// and restore it before running into use.
+			editor.on( 'contentDom', function ()
+				{
+					var title = editor.document.getElementsByTag( 'title' ).getItem( 0 );
+					title.setAttribute( '_cke_title', editor.document.$.title );
+					editor.document.$.title = frameLabel;
+				});
+
+
 			// Create an invisible element to grab focus.
-			if( CKEDITOR.env.ie )
+			if ( CKEDITOR.env.ie )
 			{
 				var ieFocusGrabber;
@@ -752,5 +751,6 @@
 				{
 					ieFocusGrabber = editor.container.append( CKEDITOR.dom.element.createFromHtml(
-					'<input tabindex="-1" style="position:absolute; left:-10000">' ) );
+						// Use 'span' instead of anything else to fly under the screen-reader radar. (#5049)
+						'<span tabindex="-1" style="position:absolute; left:-10000" role="presentation"></span>' ) );
 
 					ieFocusGrabber.on( 'focus', function()
@@ -764,17 +764,15 @@
 
 	// Fixing Firefox 'Back-Forward Cache' break design mode. (#4514)
-	if( CKEDITOR.env.gecko )
+	if ( CKEDITOR.env.gecko )
 	{
-		var topWin = window.top;
-
 		( function ()
 		{
-			var topBody = topWin.document.body;
-
-			if( !topBody )
-				topWin.addEventListener( 'load', arguments.callee, false );
+			var body = document.body;
+
+			if ( !body )
+				window.addEventListener( 'load', arguments.callee, false );
 			else
 			{
-				topBody.setAttribute( 'onpageshow', topBody.getAttribute( 'onpageshow' )
+				body.setAttribute( 'onpageshow', body.getAttribute( 'onpageshow' )
 						+ ';event.persisted && CKEDITOR.tools.callFunction(' +
 						CKEDITOR.tools.addFunction( function()
@@ -783,9 +781,9 @@
 								editor,
 								doc;
-							for( var i in allInstances )
+							for ( var i in allInstances )
 							{
 								editor = allInstances[ i ];
 								doc = editor.document;
-								if( doc )
+								if ( doc )
 								{
 									doc.$.designMode = 'off';
@@ -846,2 +844,8 @@
  */
 CKEDITOR.config.ignoreEmptyParagraph = true;
+
+/**
+ * Fired when data is loaded and ready for retrieval in an editor instance.
+ * @name CKEDITOR.editor#dataReady
+ * @event
+ */
