Index: src/wp-includes/js/quicktags.js
===================================================================
--- src/wp-includes/js/quicktags.js	(revision 32711)
+++ src/wp-includes/js/quicktags.js	(working copy)
@@ -150,7 +150,8 @@
 			zeroise( now.getUTCSeconds() ) +
 			'+00:00';
 	})(),
-	qt;
+	qt,
+	keyboardSelection = false;
 
 	qt = QTags = function(settings) {
 		if ( typeof(settings) === 'string' ) {
@@ -220,6 +221,16 @@
 			tb.attachEvent('onclick', onclick);
 		}
 
+		if ( canvas.addEventListener ) { 
+			canvas.addEventListener( 'keydown', function(event) {
+				qt.OnTab(event, this);
+			}, false );
+		} else if ( canvas.attachEvent ) { 
+			canvas.attachEvent( 'onkeydown', function(event) {
+				qt.OnTab(event, this);
+			} ); 
+		}
+
 		t.getButton = function(id) {
 			return t.theButtons[id];
 		};
@@ -243,7 +254,7 @@
 	};
 
 	qt._buttonsInit = function() {
-		var t = this, canvas, name, settings, theButtons, html, inst, ed, id, i, use,
+		var t = this, canvas, name, settings, theButtons, html, inst, ed, id, i, use, closeAllButton,
 			defaults = ',strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,';
 
 		for ( inst in t.instances ) {
@@ -294,6 +305,13 @@
 			}
 
 			ed.toolbar.innerHTML = html;
+
+			// Disable the Close All button on init. 
+			closeAllButton = document.getElementById( ed.name + '_' + theButtons.close.id ); 
+			if ( closeAllButton ) { 
+				closeAllButton.setAttribute( 'disabled', 'disabled' ); 
+			}
+
 			ed.theButtons = theButtons;
 
 			if ( typeof jQuery !== 'undefined' ) {
@@ -434,11 +452,18 @@
 	};
 	qt.TagButton.prototype = new qt.Button();
 	qt.TagButton.prototype.openTag = function(e, ed) {
-		var t = this;
+		var t = this,
+				closeAllButton = document.getElementById( ed.name + '_' + ed.theButtons.close.id );
 
+		// Enable the Close All button now that we have open tags. 
+		if ( closeAllButton ) { 
+			closeAllButton.removeAttribute( 'disabled' ); 
+		} 
+
 		if ( ! ed.openTags ) {
 			ed.openTags = [];
 		}
+
 		if ( t.tagEnd ) {
 			ed.openTags.push(t.id);
 			e.value = '/' + e.value;
@@ -445,12 +470,20 @@
 		}
 	};
 	qt.TagButton.prototype.closeTag = function(e, ed) {
-		var t = this, i = t.isOpen(ed);
+		var t = this, i = t.isOpen(ed),
+				closeAllButton = document.getElementById( ed.name + '_' + ed.theButtons.close.id ); 
 
 		if ( i !== false ) {
 			ed.openTags.splice(i, 1);
 		}
 
+		// Disable the Close All button when there are no more open tags. 
+		if ( 0 === i && closeAllButton ) { 
+			closeAllButton.setAttribute( 'disabled', 'disabled' ); 
+		} 
+		// Handle focus when the Close All button gets disabled. 
+		ed.canvas.focus(); 
+
 		e.value = t.display;
 	};
 	// whether a tag is open or not. Returns false if not open, or current open depth of the tag
@@ -469,30 +502,20 @@
 	qt.TagButton.prototype.callback = function(element, canvas, ed) {
 		var t = this, startPos, endPos, cursorPos, scrollTop, v = canvas.value, l, r, i, sel, endTag = v ? t.tagEnd : '';
 
-		if ( document.selection ) { // IE
-			canvas.focus();
-			sel = document.selection.createRange();
-			if ( sel.text.length > 0 ) {
-				if ( !t.tagEnd ) {
-					sel.text = sel.text + t.tagStart;
-				} else {
-					sel.text = t.tagStart + sel.text + endTag;
-				}
-			} else {
-				if ( !t.tagEnd ) {
-					sel.text = t.tagStart;
-				} else if ( t.isOpen(ed) === false ) {
-					sel.text = t.tagStart;
-					t.openTag(element, ed);
-				} else {
-					sel.text = endTag;
-					t.closeTag(element, ed);
-				}
+		if ( canvas.selectionStart || canvas.selectionStart === 0 ) { // FF, WebKit, Opera, IE9+
+
+			// Check if there has been a keyboard selection
+			// reverse tabbing doesn't always make canvas.selectionStart available
+			if ( keyboardSelection ) { 
+				startPos = keyboardSelection[0]; 
+				endPos = keyboardSelection[1]; 
+				// Reset it right away, no need for it from here 
+				keyboardSelection = false; 
+			} else { 
+				startPos = canvas.selectionStart; 
+				endPos = canvas.selectionEnd; 
 			}
-			canvas.focus();
-		} else if ( canvas.selectionStart || canvas.selectionStart === 0 ) { // FF, WebKit, Opera
-			startPos = canvas.selectionStart;
-			endPos = canvas.selectionEnd;
+
 			cursorPos = endPos;
 			scrollTop = canvas.scrollTop;
 			l = v.substring(0, startPos); // left of the selection
@@ -525,6 +548,31 @@
 			canvas.selectionEnd = cursorPos;
 			canvas.scrollTop = scrollTop;
 			canvas.focus();
+		} else if ( document.selection ) { // IE8
+			canvas.focus();
+			// Check if we already have an IE keyboard selection first.
+			sel = keyboardSelection || document.selection.createRange();
+
+			if ( sel.text.length > 0 ) {
+				if ( !t.tagEnd ) {
+					sel.text = sel.text + t.tagStart;
+				} else {
+					sel.text = t.tagStart + sel.text + endTag;
+				}
+			} else {
+				if ( !t.tagEnd ) {
+					sel.text = t.tagStart;
+				} else if ( t.isOpen(ed) === false ) {
+					sel.text = t.tagStart;
+					t.openTag(element, ed);
+				} else {
+					sel.text = endTag;
+					t.closeTag(element, ed);
+				}
+			}
+			// Reset IE keyboard selection
+			keyboardSelection = false; 
+			canvas.focus();
 		} else { // other browsers?
 			if ( !endTag ) {
 				canvas.value += t.tagStart;
@@ -539,6 +587,24 @@
 		}
 	};
 
+	// IE keyboard selection: get and store the selection when reverse tabbing. 
+	qt.OnTab = function( event, canvas ) {
+		var key;
+
+		if ( ( document.selection || document.getSelection() ) && 'keydown' === event.type ) {
+			key = event.keyCode || event.charCode;
+			if ( event.shiftKey && 9 === key ) {
+
+				if ( canvas.selectionStart || canvas.selectionStart === 0 ) {
+					keyboardSelection = [canvas.selectionStart, canvas.selectionEnd];
+				} else  if ( document.selection ) {
+					keyboardSelection = document.selection.createRange();
+				}
+
+			}
+		}
+	}; 
+
 	// removed
 	qt.SpellButton = function() {};
 
