Index: src/wp-includes/class-wp-editor.php
===================================================================
--- src/wp-includes/class-wp-editor.php	(revision 31940)
+++ src/wp-includes/class-wp-editor.php	(working copy)
@@ -1436,45 +1436,44 @@
 		// display: none is required here, see #WP27605
 		?>
 		<div id="wp-link-backdrop" style="display: none"></div>
-		<div id="wp-link-wrap" class="wp-core-ui<?php echo $search_panel_visible; ?>" style="display: none">
+		<div id="wp-link-wrap" class="wp-core-ui<?php echo $search_panel_visible; ?>" style="display: none" role="dialog" aria-labelledby="link-modal-title" tabindex="0">
 		<form id="wp-link" tabindex="-1">
 		<?php wp_nonce_field( 'internal-linking', '_ajax_linking_nonce', false ); ?>
-		<div id="link-modal-title">
-			<?php _e( 'Insert/edit link' ) ?>
-			<button type="button" id="wp-link-close"><span class="screen-reader-text"><?php _e( 'Close' ); ?></span></button>
-	 	</div>
+		<h1 id="link-modal-title"><?php _e( 'Insert/edit link' ) ?></h1>
+		<button type="button" id="wp-link-close"><span class="screen-reader-text"><?php _e( 'Close' ); ?></span></button>
 		<div id="link-selector">
 			<div id="link-options">
-				<p class="howto"><?php _e( 'Enter the destination URL' ); ?></p>
+				<p class="howto" id="wp-link-howto-url"><?php _e( 'Enter the destination URL' ); ?></p>
 				<div class="wp-link-text-field">
 					<label><span><?php _e( 'Link Text' ); ?></span><input id="wp-link-text" type="text" /></label>
 				</div>
 				<div>
-					<label><span><?php _e( 'URL' ); ?></span><input id="wp-link-url" type="text" /></label>
+					<label><span><?php _e( 'URL' ); ?></span><input id="wp-link-url" type="text" aria-describedby="wp-link-howto-url" /></label>
 				</div>
 				<div class="link-target">
-					<label><span>&nbsp;</span><input type="checkbox" id="wp-link-target" /> <?php _e( 'Open link in a new window/tab' ); ?></label>
+					<label><span></span><input type="checkbox" id="wp-link-target" /> <?php _e( 'Open link in a new window/tab' ); ?></label>
 				</div>
 			</div>
-			<p class="howto"><a href="#" id="wp-link-search-toggle"><?php _e( 'Or link to existing content' ); ?></a></p>
+			<div class="howto"><button type="button" id="wp-link-search-toggle" class="button" aria-expanded="false"><?php _e( 'Or link to existing content' ); ?></button></div>
 			<div id="search-panel">
 				<div class="link-search-wrapper">
 					<label>
-						<span class="search-label"><?php _e( 'Search' ); ?></span>
-						<input type="search" id="wp-link-search" class="link-search-field" autocomplete="off" />
+						<span class="search-label"><?php _e( 'Search' ); ?></span><input type="search" id="wp-link-search" class="link-search-field" autocomplete="off" aria-describedby="query-notice-hint" />
 						<span class="spinner"></span>
 					</label>
 				</div>
-				<div id="search-results" class="query-results" tabindex="0">
-					<ul></ul>
-					<div class="river-waiting">
-						<span class="spinner"></span>
+				<div role="application" aria-label="<?php esc_attr_e( 'Links:' ); ?>">
+					<div id="search-results" class="query-results" tabindex="0" role="list" aria-label="<?php esc_attr_e( 'Search results:' ); ?>">
+						<ul aria-live="polite" aria-relevant="all" aria-atomic="true"></ul>
+						<div class="river-waiting">
+							<span class="spinner"></span>
+						</div>
 					</div>
 				</div>
-				<div id="most-recent-results" class="query-results" tabindex="0">
+				<div id="most-recent-results" class="query-results" tabindex="0" role="list" aria-labelledby="query-notice-default">
 					<div class="query-notice" id="query-notice-message">
-						<em class="query-notice-default"><?php _e( 'No search term specified. Showing recent items.' ); ?></em>
-						<em class="query-notice-hint screen-reader-text"><?php _e( 'Search or use up and down arrow keys to select an item.' ); ?></em>
+						<em class="query-notice-default" id="query-notice-default"><?php _e( 'No search term specified. Showing recent items.' ); ?></em>
+						<em class="query-notice-hint screen-reader-text" id="query-notice-hint"><?php _e( 'Search or use up and down arrow keys to select an item.' ); ?></em>
 					</div>
 					<ul></ul>
 					<div class="river-waiting">
@@ -1485,7 +1484,7 @@
 		</div>
 		<div class="submitbox">
 			<div id="wp-link-cancel">
-				<a class="submitdelete deletion" href="#"><?php _e( 'Cancel' ); ?></a>
+				<button type="button" id="wp-link-cancel-button" class="button"><?php _e( 'Cancel' ); ?></button>
 			</div>
 			<div id="wp-link-update">
 				<input type="submit" value="<?php esc_attr_e( 'Add Link' ); ?>" class="button button-primary" id="wp-link-submit" name="wp-link-submit">
Index: src/wp-includes/css/editor.css
===================================================================
--- src/wp-includes/css/editor.css	(revision 31940)
+++ src/wp-includes/css/editor.css	(working copy)
@@ -920,7 +920,7 @@
 	padding: 10px;
 	margin: 1px 0 0;
 	line-height: 150%;
-	border: 0 none;
+	border: 0;
 	outline: none;
 	display: block;
 	resize: vertical;
@@ -1220,8 +1220,8 @@
 }
 
 #wp-link-wrap.search-panel-visible {
-	height: 500px;
-	margin-top: -250px;
+	height: 510px;
+	margin-top: -255px;
 }
 
 #wp-link-wrap .wp-link-text-field {
@@ -1239,10 +1239,8 @@
 	font-size: 18px;
 	font-weight: 600;
 	line-height: 36px;
+	margin: 0;
 	padding: 0 36px 0 16px;
-	top: 0;
-	right: 0;
-	left: 0;
 }
 
 #wp-link-close {
@@ -1307,7 +1305,7 @@
 
 #wp-link-search-toggle:after {
 	display: inline-block;
-	font: normal 20px/1 'dashicons';
+	font: normal 20px/26px 'dashicons';
 	vertical-align: top;
 	speak: none;
 	-webkit-font-smoothing: antialiased;
@@ -1329,6 +1327,10 @@
 	padding: 8px 0 12px;
 }
 
+#wp-link div.howto {
+	margin: 0 0 12px 85px;
+}
+
 #wp-link p.howto {
 	margin: 3px 0;
 }
@@ -1338,11 +1340,8 @@
 	color: inherit;
 }
 
-#wp-link-search-toggle {
-	cursor: pointer;
-}
-
-#wp-link label input[type="text"] {
+#wp-link label input[type="text"],
+#wp-link label input[type="search"] {
 	margin-top: 5px;
 	width: 70%;
 }
@@ -1356,12 +1355,6 @@
 	max-width: 24%;
 }
 
-#wp-link .link-search-field {
-	float: left;
-	width: 250px;
-	max-width: 70%;
-}
-
 #wp-link .link-search-wrapper {
 	margin: 5px 0 9px;
 	display: block;
@@ -1368,14 +1361,10 @@
 	overflow: hidden;
 }
 
-#wp-link .link-search-wrapper span {
-	float: left;
-	margin-top: 4px;
-}
-
 #wp-link .link-search-wrapper .spinner {
 	display: none;
 	vertical-align: text-bottom;
+	margin: 8px 20px 0 0;
 }
 
 #wp-link .link-target {
@@ -1383,12 +1372,9 @@
 	white-space: nowrap;
 	overflow: hidden;
 	text-overflow: ellipsis;
+	max-width: 90%;
 }
 
-#wp-link .link-target label {
-	max-width: 70%;
-}
-
 #wp-link .query-results {
 	border: 1px #dfdfdf solid;
 	margin: 0;
@@ -1402,7 +1388,7 @@
 }
 
 .has-text-field #wp-link .query-results {
-	top: 205px;
+	top: 215px;
 }
 
 #wp-link li {
@@ -1413,6 +1399,7 @@
 	padding: 4px 6px 4px 10px;
 	cursor: pointer;
 	position: relative;
+	outline: 0;
 }
 
 #wp-link .query-notice {
@@ -1544,7 +1531,7 @@
 	}
 
 	#wp-link-wrap.search-panel-visible.has-text-field .query-results {
-		top: 235px;
+		top: 270px;
 	}
 
 	#link-selector {
@@ -1558,6 +1545,22 @@
 	#wp-link-cancel {
 		line-height: 32px;
 	}
+
+	#wp-link .link-target {
+		padding-top: 10px;
+	}
+
+	#wp-link-search-toggle {
+		line-height: 26px;
+	}
+
+	#wp-link-wrap.search-panel-visible #link-selector {
+		bottom: 48px;
+	}
+
+	#wp-link .link-search-wrapper .spinner {
+		margin-top: 12px;
+	}
 }
 
 @media screen and ( max-width: 520px ) {
@@ -1901,8 +1904,8 @@
 
 #wp-fullscreen-buttons .mce-btn button {
     margin: 0;
-    outline: 0 none;
-    border: 0 none;
+    outline: 0;
+    border: 0;
     white-space: nowrap;
     width: auto;
     background: none;
Index: src/wp-includes/js/wplink.js
===================================================================
--- src/wp-includes/js/wplink.js	(revision 31940)
+++ src/wp-includes/js/wplink.js	(working copy)
@@ -5,7 +5,8 @@
 	var editor, searchTimer, River, Query, correctedURL,
 		inputs = {},
 		rivers = {},
-		isTouch = ( 'ontouchend' in document );
+		isTouch = ( 'ontouchend' in document ),
+		visible;
 
 	function getLink() {
 		return editor.dom.getParent( editor.selection.getNode(), 'a' );
@@ -15,7 +16,7 @@
 		timeToTriggerRiver: 150,
 		minRiverAJAXDuration: 200,
 		riverBottomThreshold: 5,
-		keySensitivity: 100,
+		keySensitivity: 150,
 		lastSearch: '',
 		textarea: '',
 
@@ -31,6 +32,7 @@
 			inputs.url = $( '#wp-link-url' );
 			inputs.nonce = $( '#_ajax_linking_nonce' );
 			inputs.openInNewTab = $( '#wp-link-target' );
+			inputs.searchToggle = $( '#wp-link-search-toggle' );
 			inputs.search = $( '#wp-link-search' );
 
 			// Build Rivers
@@ -50,12 +52,12 @@
 				event.preventDefault();
 				wpLink.update();
 			});
-			inputs.close.add( inputs.backdrop ).add( '#wp-link-cancel a' ).click( function( event ) {
+			inputs.close.add( inputs.backdrop ).add( '#wp-link-cancel-button' ).click( function( event ) {
 				event.preventDefault();
 				wpLink.close();
 			});
 
-			$( '#wp-link-search-toggle' ).on( 'click', wpLink.toggleInternalLinking );
+			inputs.searchToggle.on( 'click', wpLink.toggleInternalLinking );
 
 			rivers.elements.on( 'river-select', wpLink.updateFields );
 
@@ -145,6 +147,7 @@
 			// Refresh rivers (clear links, check visibility)
 			rivers.search.refresh();
 			rivers.recent.refresh();
+			visible = inputs.wrap.hasClass( 'search-panel-visible' );
 
 			if ( wpLink.isMCE() ) {
 				wpLink.mceRefresh();
@@ -156,12 +159,12 @@
 
 			if ( isTouch ) {
 				// Close the onscreen keyboard
-				inputs.url.focus().blur();
+				inputs.text.focus().blur();
 			} else {
 				// Focus the URL field and highlight its contents.
 				// If this is moved above the selection changes,
 				// IE will show a flashing cursor over the dialog.
-				inputs.url.focus()[0].select();
+				inputs.text.focus()[0].select();
 			}
 
 			// Load the most recent results if this is the first time opening the panel.
@@ -170,6 +173,13 @@
 			}
 
 			correctedURL = inputs.url.val().replace( /^http:\/\//, '' );
+
+			// Toggle the button aria-expanded attribute.
+			if ( visible ) {
+				inputs.searchToggle.attr( 'aria-expanded', 'true' );
+			} else {
+				inputs.searchToggle.attr( 'aria-expanded', 'false' );
+			}
 		},
 
 		hasSelectedText: function( linkNode ) {
@@ -401,8 +411,9 @@
 				rivers.search.show();
 
 				// Don't search if the keypress didn't change the title.
-				if ( wpLink.lastSearch == search )
+				if ( wpLink.lastSearch == search ) {
 					return;
+				}
 
 				wpLink.lastSearch = search;
 				waiting = t.parent().find('.spinner').show();
@@ -452,8 +463,15 @@
 				return;
 			}
 
-			if ( document.activeElement &&
-				( document.activeElement.id === 'link-title-field' || document.activeElement.id === 'url-field' ) ) {
+			if ( document.activeElement && (
+				'wp-link-close' === document.activeElement.id ||
+				'link-title-field' === document.activeElement.id ||
+				'url-field' === document.activeElement.id ||
+				'link-target-checkbox' === document.activeElement.id ||
+				'wp-link-search-toggle' === document.activeElement.id ||
+				'wp-link-cancel-button' === document.activeElement.id ||
+				'wp-link-submit' === document.activeElement.id
+				) ) {
 				return;
 			}
 
@@ -476,19 +494,22 @@
 		delayedCallback: function( func, delay ) {
 			var timeoutTriggered, funcTriggered, funcArgs, funcContext;
 
-			if ( ! delay )
+			if ( ! delay ) {
 				return func;
+			}
 
 			setTimeout( function() {
-				if ( funcTriggered )
+				if ( funcTriggered ) {
 					return func.apply( funcContext, funcArgs );
+				}
 				// Otherwise, wait.
 				timeoutTriggered = true;
 			}, delay );
 
 			return function() {
-				if ( timeoutTriggered )
+				if ( timeoutTriggered ) {
 					return func.apply( this, arguments );
+				}
 				// Otherwise, wait.
 				funcArgs = arguments;
 				funcContext = this;
@@ -497,11 +518,16 @@
 		},
 
 		toggleInternalLinking: function( event ) {
-			var visible = inputs.wrap.hasClass( 'search-panel-visible' );
+			visible = inputs.wrap.hasClass( 'search-panel-visible' );
 
 			inputs.wrap.toggleClass( 'search-panel-visible', ! visible );
 			setUserSetting( 'wplink', visible ? '0' : '1' );
-			inputs[ ! visible ? 'search' : 'url' ].focus();
+			if ( ! visible ) {
+				inputs.search.focus();
+				inputs.searchToggle.attr( 'aria-expanded', 'true' );
+			} else {
+				inputs.searchToggle.attr( 'aria-expanded', 'false' );
+			}
 			event.preventDefault();
 		}
 	};
@@ -544,11 +570,12 @@
 		select: function( li, event ) {
 			var liHeight, elHeight, liTop, elTop;
 
-			if ( li.hasClass( 'unselectable' ) || li == this.selected )
-				return;
+			if ( li.hasClass( 'unselectable' ) || li == this.selected ) {
+ 				return;
+			}
 
 			this.deselect();
-			this.selected = li.addClass( 'selected' );
+			this.selected = li.addClass( 'selected' ).attr( 'aria-selected', 'true' ).focus();
 			// Make sure the element is visible
 			liHeight = li.outerHeight();
 			elHeight = this.element.height();
@@ -555,37 +582,43 @@
 			liTop = li.position().top;
 			elTop = this.element.scrollTop();
 
-			if ( liTop < 0 ) // Make first visible element
+			if ( liTop < 0 ) { // Make first visible element
 				this.element.scrollTop( elTop + liTop );
-			else if ( liTop + liHeight > elHeight ) // Make last visible element
+			} else if ( liTop + liHeight > elHeight ) { // Make last visible element
 				this.element.scrollTop( elTop + liTop - elHeight + liHeight );
+			}
 
 			// Trigger the river-select event
 			this.element.trigger( 'river-select', [ li, event, this ] );
 		},
 		deselect: function() {
-			if ( this.selected )
-				this.selected.removeClass( 'selected' );
+			if ( this.selected ) {
+				this.selected.removeClass( 'selected' ).attr( 'aria-selected', 'false' );
+			}
 			this.selected = false;
 		},
 		prev: function() {
-			if ( ! this.visible )
+			if ( ! this.visible ) {
 				return;
+			}
 
 			var to;
 			if ( this.selected ) {
 				to = this.selected.prev( 'li' );
-				if ( to.length )
+				if ( to.length ) {
 					this.select( to );
+				}
 			}
 		},
 		next: function() {
-			if ( ! this.visible )
+			if ( ! this.visible ) {
 				return;
+			}
 
 			var to = this.selected ? this.selected.next( 'li' ) : $( 'li:not(.unselectable):first', this.element );
-			if ( to.length )
+			if ( to.length ) {
 				this.select( to );
+			}
 		},
 		ajax: function( callback ) {
 			var self = this,
@@ -592,15 +625,17 @@
 				delay = this.query.page == 1 ? 0 : wpLink.minRiverAJAXDuration,
 				response = wpLink.delayedCallback( function( results, params ) {
 					self.process( results, params );
-					if ( callback )
+					if ( callback ) {
 						callback( results, params );
+					}
 				}, delay );
 
 			this.query.ajax( response );
 		},
 		change: function( search ) {
-			if ( this.query && this._search == search )
+			if ( this.query && this._search == search ) {
 				return;
+			}
 
 			this._search = search;
 			this.query = new Query( search );
@@ -619,7 +654,7 @@
 				$.each( results, function() {
 					classes = alt ? 'alternate' : '';
 					classes += this.title ? '' : ' no-title';
-					list += classes ? '<li class="' + classes + '">' : '<li>';
+					list += classes ? '<li class="' + classes + '" tabindex="-1" role="listitem">' : '<li tabindex="-1" role="listitem">';
 					list += '<input type="hidden" class="item-permalink" value="' + this.permalink + '" />';
 					list += '<span class="item-title">';
 					list += this.title ? this.title : wpLinkL10n.noTitle;
@@ -635,15 +670,17 @@
 				el = this.element,
 				bottom = el.scrollTop() + el.height();
 
-			if ( ! this.query.ready() || bottom < this.contentHeight.height() - wpLink.riverBottomThreshold )
+			if ( ! this.query.ready() || bottom < this.contentHeight.height() - wpLink.riverBottomThreshold ) {
 				return;
+			}
 
 			setTimeout(function() {
 				var newTop = el.scrollTop(),
 					newBottom = newTop + el.height();
 
-				if ( ! self.query.ready() || newBottom < self.contentHeight.height() - wpLink.riverBottomThreshold )
+				if ( ! self.query.ready() || newBottom < self.contentHeight.height() - wpLink.riverBottomThreshold ) {
 					return;
+				}
 
 				self.waiting.show();
 				el.scrollTop( newTop + self.waiting.outerHeight() );
@@ -674,8 +711,9 @@
 					'_ajax_linking_nonce' : inputs.nonce.val()
 				};
 
-			if ( this.search )
+			if ( this.search ) {
 				query.search = this.search;
+			}
 
 			this.querying = true;
 
