Auto merge of #10176 - mbrubeck:selection-range, r=pcwalton

Highlight selected text in input fields

Fixes #9993.  This does not yet allow stylesheets to set the selection colors; instead it uses a hard-coded orange background and white foreground.

r? @pcwalton

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10176)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-03-26 08:16:20 +05:30
commit bed91b3334
17 changed files with 264 additions and 77 deletions

View file

@ -2540,6 +2540,30 @@
"url": "/_mozilla/css/input_placeholder_ref.html"
}
],
"css/input_selection_a.html": [
{
"path": "css/input_selection_a.html",
"references": [
[
"/_mozilla/css/input_selection_ref.html",
"=="
]
],
"url": "/_mozilla/css/input_selection_a.html"
}
],
"css/input_selection_ref.html": [
{
"path": "css/input_selection_ref.html",
"references": [
[
"/_mozilla/css/input_selection_ref.html",
"=="
]
],
"url": "/_mozilla/css/input_selection_ref.html"
}
],
"css/input_whitespace.html": [
{
"path": "css/input_whitespace.html",
@ -8842,6 +8866,30 @@
"url": "/_mozilla/css/input_placeholder_ref.html"
}
],
"css/input_selection_a.html": [
{
"path": "css/input_selection_a.html",
"references": [
[
"/_mozilla/css/input_selection_ref.html",
"=="
]
],
"url": "/_mozilla/css/input_selection_a.html"
}
],
"css/input_selection_ref.html": [
{
"path": "css/input_selection_ref.html",
"references": [
[
"/_mozilla/css/input_selection_ref.html",
"=="
]
],
"url": "/_mozilla/css/input_selection_ref.html"
}
],
"css/input_whitespace.html": [
{
"path": "css/input_whitespace.html",

View file

@ -0,0 +1,28 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>input selection test</title>
<link rel="match" href="input_selection_ref.html">
<style>
input {
font: 16px sans-serif;
border: 0 none;
margin: 0;
padding: 0;
}
::selection {
color: white;
background: rgba(255, 127, 0, 1.0);
}
</style>
</head>
<body>
<input value="Hello">
<script>
var input = document.querySelector("input");
input.focus();
input.setSelectionRange(0, 5);
</script>
</body>
</html>

View file

@ -0,0 +1,18 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>input selection test</title>
<link rel="match" href="input_selection_ref.html">
<style>
span {
font: 16px sans-serif;
color: white;
background: rgba(255, 128, 0, 1.0);
}
</style>
</head>
<body>
<span>Hello</span>
</body>
</html>