Index: wp-includes/general-template.php
===================================================================
--- wp-includes/general-template.php	(revision 18836)
+++ wp-includes/general-template.php	(working copy)
@@ -1714,21 +1714,17 @@
  * @return bool
  */
 function user_can_richedit() {
-	global $wp_rich_edit, $pagenow, $is_iphone;
+	global $current_web_browser;
+	static $can_richedit = null;
 
-	if ( !isset( $wp_rich_edit) ) {
-		if ( get_user_option( 'rich_editing' ) == 'true' &&
-			!$is_iphone && // this includes all Safari mobile browsers
-			( ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval($match[1]) >= 420 ) ||
-				!preg_match( '!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT'] ) )
-		) {
-			$wp_rich_edit = true;
-		} else {
-			$wp_rich_edit = false;
-		}
+	if ( $can_richedit === null ) {
+		if ( get_user_option( 'rich_editing' ) == 'true' && !empty($current_web_browser['richedit']) )
+			$can_richedit = true;
+		else
+			$can_richedit = false;
 	}
 
-	return apply_filters('user_can_richedit', $wp_rich_edit);
+	return apply_filters('user_can_richedit', $can_richedit);
 }
 
 /**
Index: wp-includes/vars.php
===================================================================
--- wp-includes/vars.php	(revision 18836)
+++ wp-includes/vars.php	(working copy)
@@ -43,9 +43,21 @@
 // Simple browser detection
 $is_lynx = $is_gecko = $is_winIE = $is_macIE = $is_opera = $is_NS4 = $is_safari = $is_chrome = $is_iphone = false;
 
+$current_web_browser = array(
+	'name' => '',
+	'engine' => '',
+	'engine_version' => '',
+	'os' => '',
+	'device' => '',
+	'richedit' => false,
+	'platform' => ''
+);
+
 if ( isset($_SERVER['HTTP_USER_AGENT']) ) {
-	if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Lynx') !== false ) {
+	if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Lynx') !== false ) { // is this still needed?
 		$is_lynx = true;
+		$current_web_browser['name'] = 'Lynx';
+		$current_web_browser['os'] = 'Linux';
 	} elseif ( stripos($_SERVER['HTTP_USER_AGENT'], 'chrome') !== false ) {
 		if ( stripos( $_SERVER['HTTP_USER_AGENT'], 'chromeframe' ) !== false ) {
 			if ( $is_chrome = apply_filters( 'use_google_chrome_frame', is_admin() ) )
@@ -54,26 +66,65 @@
 		} else {
 			$is_chrome = true;
 		}
+		$current_web_browser['name'] = 'Chrome';
+		$current_web_browser['engine'] = 'WebKit';
 	} elseif ( stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false ) {
 		$is_safari = true;
+		$current_web_browser['name'] = 'Safari';
+		$current_web_browser['engine'] = 'WebKit';
 	} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false ) {
 		$is_gecko = true;
-	} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Win') !== false ) {
-		$is_winIE = true;
-	} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false ) {
-		$is_macIE = true;
+		$current_web_browser['engine'] = 'Gecko';
+
+		if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false )
+			$current_web_browser['name'] = 'Firefox';
+
+	} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false ) {
+		$is_IE = $is_winIE = true;
+		$current_web_browser['name'] = $current_web_browser['engine'] = 'MSIE';
 	} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false ) {
 		$is_opera = true;
-	} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Nav') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla/4.') !== false ) {
-		$is_NS4 = true;
+		$current_web_browser['name'] = 'Opera';
+		$current_web_browser['engine'] = 'Presto';
 	}
 }
 
-if ( $is_safari && stripos($_SERVER['HTTP_USER_AGENT'], 'mobile') !== false )
-	$is_iphone = true;
+function _current_web_browser() {
+	global $current_web_browser, $is_safari, $is_iphone;
 
-$is_IE = ( $is_macIE || $is_winIE );
+	$matches = array();
+	if ( stripos($_SERVER['HTTP_USER_AGENT'], 'mobile') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mini') !== false ) {
+		$current_web_browser['platform'] = 'mobile';
 
+		if ( preg_match('/(iphone|ipod|ipad|blackberry|android)/i', $_SERVER['HTTP_USER_AGENT'], $matches) )
+			$current_web_browser['device'] = $matches[1];
+
+		// back compat
+		if ( $is_safari )
+			$is_iphone = true;
+
+	} elseif ( preg_match('/(spider|crawl|slurp|bot)/i', $_SERVER['HTTP_USER_AGENT']) ) {
+		$current_web_browser['platform'] = 'bot';
+	}
+
+	if ( preg_match('/(windows|linux|macintosh|solaris|bsd)/i', $_SERVER['HTTP_USER_AGENT'], $matches) ) {
+		$current_web_browser['os'] = $matches[1];
+
+		if ( empty($current_web_browser['platform']) ) {
+			$current_web_browser['platform'] = 'desktop';
+			$current_web_browser['device'] = 'pc'; // includes laptops
+			$current_web_browser['richedit'] = true;
+		}
+	}
+
+	if ( preg_match('!(?:AppleWebKit/|Gecko/|Presto/|MSIE )([0-9.]+)!', $_SERVER['HTTP_USER_AGENT'], $matches) )
+		$current_web_browser['engine_version'] = round( (float) $matches[1], 2 );
+
+	if ( $current_web_browser['engine'] == 'WebKit' && $current_web_browser['engine_version'] >= 534 )
+		$current_web_browser['richedit'] = true;
+}
+_current_web_browser();
+
 // Server detection
 
 /**
@@ -94,4 +145,4 @@
  */
 $is_iis7 = $is_IIS && (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7.') !== false);
 
-?>
\ No newline at end of file
+?>
