Index: src/wp-includes/class-wp-editor.php
===================================================================
--- src/wp-includes/class-wp-editor.php	(revision 30514)
+++ src/wp-includes/class-wp-editor.php	(working copy)
@@ -1406,56 +1406,56 @@
 		// 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>
-					<label><span><?php _e( 'URL' ); ?></span><input id="url-field" type="text" name="href" /></label>
+					<label><span><?php _e( 'URL' ); ?></span><input id="url-field" type="text" name="href" aria-describedby="wp-link-howto-url" /></label>
 				</div>
 				<div>
 					<label><span><?php _e( 'Title' ); ?></span><input id="link-title-field" type="text" name="linktitle" /></label>
 				</div>
 				<div class="link-target">
-					<label><span>&nbsp;</span><input type="checkbox" id="link-target-checkbox" /> <?php _e( 'Open link in a new window/tab' ); ?></label>
+					<label><span></span><input type="checkbox" id="link-target-checkbox" /> <?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="search-field" class="link-search-field" autocomplete="off" />
+						<input type="search" id="search-field" 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"></ul>
+						<div class="river-waiting">
+							<span class="spinner"></span>
+						</div>
 					</div>
-				</div>
-				<div id="most-recent-results" class="query-results" tabindex="0">
-					<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>
+					<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" 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">
+							<span class="spinner"></span>
+						</div>
 					</div>
-					<ul></ul>
-					<div class="river-waiting">
-						<span class="spinner"></span>
-					</div>
 				</div>
 			</div>
 		</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 30514)
+++ src/wp-includes/css/editor.css	(working copy)
@@ -158,8 +158,8 @@
 	border: 1px solid #aaa;
 	-webkit-border-radius: 2px;
 	border-radius: 2px;
-	-webkit-box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.2 )
-	box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.2 )
+	-webkit-box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.2 );
+	box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.2 );
 	-webkit-box-sizing: border-box;
 	-moz-box-sizing: border-box;
 	-webkit-box-sizing: border-box;
@@ -919,7 +919,7 @@
 	padding: 10px;
 	margin: 1px 0 0;
 	line-height: 150%;
-	border: 0 none;
+	border: 0;
 	outline: none;
 	display: block;
 	resize: vertical;
@@ -1183,7 +1183,7 @@
 	-webkit-box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
 	box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
 	width: 500px;
-	height: 250px;
+	height: 260px;
 	overflow: hidden;
 	margin-left: -250px;
 	margin-top: -125px;
@@ -1215,8 +1215,8 @@
 }
 
 #wp-link-wrap.search-panel-visible {
-	height: 500px;
-	margin-top: -250px;
+	height: 510px;
+	margin-top: -255px;
 }
 
 #link-modal-title {
@@ -1226,10 +1226,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 {
@@ -1294,7 +1292,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;
@@ -1320,15 +1318,15 @@
 	margin: 3px 0;
 }
 
+#wp-link div.howto {
+	margin: 0 0 12px 85px;
+}
+
 #wp-link p.howto a {
 	text-decoration: none;
 	color: inherit;
 }
 
-#wp-link-search-toggle {
-	cursor: pointer;
-}
-
 #wp-link label input[type="text"] {
 	margin-top: 5px;
 	width: 70%;
@@ -1345,8 +1343,7 @@
 
 #wp-link .link-search-field {
 	float: left;
-	width: 250px;
-	max-width: 70%;
+	width: 70%;
 }
 
 #wp-link .link-search-wrapper {
@@ -1370,12 +1367,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;
@@ -1385,7 +1379,7 @@
 	left: 16px;
 	right: 16px;
 	bottom: 16px;
-	top: 205px;
+	top: 215px;
 }
 
 #wp-link li {
@@ -1396,6 +1390,7 @@
 	padding: 4px 6px 4px 10px;
 	cursor: pointer;
 	position: relative;
+	outline: 0;
 }
 
 #wp-link .query-notice {
@@ -1881,8 +1876,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 30514)
+++ src/wp-includes/js/wplink.js	(working copy)
@@ -5,13 +5,14 @@
 	var editor, searchTimer, River, Query,
 		inputs = {},
 		rivers = {},
-		isTouch = ( 'ontouchend' in document );
+		isTouch = ( 'ontouchend' in document ),
+		visible;
 
 	wpLink = {
 		timeToTriggerRiver: 150,
 		minRiverAJAXDuration: 200,
 		riverBottomThreshold: 5,
-		keySensitivity: 100,
+		keySensitivity: 150,
 		lastSearch: '',
 		textarea: '',
 
@@ -28,6 +29,7 @@
 			inputs.title = $( '#link-title-field' );
 			// Advanced Options
 			inputs.openInNewTab = $( '#link-target-checkbox' );
+			inputs.searchToggle = $( '#wp-link-search-toggle' );
 			inputs.search = $( '#search-field' );
 			// Build Rivers
 			rivers.search = new River( $( '#search-results' ) );
@@ -46,12 +48,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 );
 
@@ -110,6 +112,7 @@
 
 			inputs.wrap.show();
 			inputs.backdrop.show();
+			$( 'body' ).addClass( 'modal-open' );
 
 			wpLink.refresh();
 			$( document ).trigger( 'wplink-open', inputs.wrap );
@@ -123,6 +126,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();
@@ -144,6 +148,13 @@
 			if ( ! rivers.recent.ul.children().length ) {
 				rivers.recent.ajax();
 			}
+
+			// Toggle the button aria-expanded attribute.
+			if ( visible ) {
+				inputs.searchToggle.attr( 'aria-expanded', 'true' );
+			} else {
+				inputs.searchToggle.attr( 'aria-expanded', 'false' );
+			}
 		},
 
 		mceRefresh: function() {
@@ -179,6 +190,7 @@
 
 			inputs.backdrop.hide();
 			inputs.wrap.hide();
+			$( 'body' ).removeClass( 'modal-open' );
 			$( document ).trigger( 'wplink-close', inputs.wrap );
 		},
 
@@ -191,10 +203,11 @@
 		},
 
 		update: function() {
-			if ( wpLink.isMCE() )
+			if ( wpLink.isMCE() ) {
 				wpLink.mceUpdate();
-			else
+			} else {
 				wpLink.htmlUpdate();
+			}
 		},
 
 		htmlUpdate: function() {
@@ -201,14 +214,16 @@
 			var attrs, html, begin, end, cursor, title, selection,
 				textarea = wpLink.textarea;
 
-			if ( ! textarea )
+			if ( ! textarea ) {
 				return;
+			}
 
 			attrs = wpLink.getAttrs();
 
 			// If there's no href, return.
-			if ( ! attrs.href || attrs.href == 'http://' )
+			if ( ! attrs.href || attrs.href == 'http://' ) {
 				return;
+			}
 
 			// Build HTML
 			html = '<a href="' + attrs.href + '"';
@@ -244,8 +259,9 @@
 				cursor      = begin + html.length;
 
 				// If no text is selected, place the cursor inside the closing tag.
-				if ( begin == end )
+				if ( begin == end ) {
 					cursor -= '</a>'.length;
+				}
 
 				textarea.value = textarea.value.substring( 0, begin ) + html +
 					textarea.value.substring( end, textarea.value.length );
@@ -324,8 +340,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();
@@ -375,8 +392,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;
 			}
 
@@ -399,19 +423,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;
@@ -420,11 +447,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();
 		}
 	};
@@ -467,11 +499,12 @@
 		select: function( li, event ) {
 			var liHeight, elHeight, liTop, elTop;
 
-			if ( li.hasClass( 'unselectable' ) || li == this.selected )
+			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();
@@ -478,37 +511,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,
@@ -515,15 +554,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 );
@@ -542,7 +583,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;
@@ -558,15 +599,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() );
@@ -597,8 +640,9 @@
 					'_ajax_linking_nonce' : inputs.nonce.val()
 				};
 
-			if ( this.search )
+			if ( this.search ) {
 				query.search = this.search;
+			}
 
 			this.querying = true;
 
