|
1 <!DOCTYPE HTML> |
|
2 <!-- |
|
3 Any copyright is dedicated to the Public Domain. |
|
4 http://creativecommons.org/licenses/publicdomain/ |
|
5 |
|
6 Test: Selected text, background, decorations |
|
7 --> |
|
8 <html class="reftest-wait"><head> |
|
9 <title>text-overflow: Selected text, background, decorations</title> |
|
10 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> |
|
11 <style type="text/css"> |
|
12 @font-face { |
|
13 font-family: DejaVuSansMono; |
|
14 src: url(../fonts/DejaVuSansMono.woff); |
|
15 } |
|
16 @font-face { |
|
17 font-family: TestEllipsisFallback; |
|
18 src: url(TestEllipsisFallback.woff); |
|
19 } |
|
20 html,body { |
|
21 color:black; background-color:white; font-size:16px; padding:0; margin:0; font-family:DejaVuSansMono; |
|
22 } |
|
23 |
|
24 .test { |
|
25 overflow:auto; |
|
26 text-overflow:ellipsis ellipsis; |
|
27 white-space:nowrap; |
|
28 width: 5em; |
|
29 position:relative; |
|
30 margin-top:1em; |
|
31 padding-left: 0.9em; |
|
32 padding-right: 1.3em; |
|
33 } |
|
34 |
|
35 .hidden { |
|
36 overflow:hidden; |
|
37 width: 4.4em; |
|
38 } |
|
39 |
|
40 .rlo { |
|
41 unicode-bidi: bidi-override; direction: rtl; |
|
42 } |
|
43 .lro { |
|
44 unicode-bidi: bidi-override; direction: ltr; |
|
45 } |
|
46 .rtl { |
|
47 direction:rtl; |
|
48 } |
|
49 x {font-family:DejaVuSansMono;} |
|
50 </style> |
|
51 <script> |
|
52 function getTextNode(elm) { |
|
53 if (elm.nodeType != 3) |
|
54 return getTextNode(elm.firstChild); |
|
55 return elm; |
|
56 } |
|
57 function addRange(elm) { |
|
58 try { |
|
59 var sel = window.getSelection(); |
|
60 var range = document.createRange(); |
|
61 var startNode = elm.getAttribute('startNode'); |
|
62 if (startNode == null) |
|
63 startNode = getTextNode(elm); |
|
64 else |
|
65 startNode = getTextNode(elm.childNodes[startNode]) |
|
66 var start = elm.getAttribute('start'); |
|
67 if (start == null) start = 2; |
|
68 var endNode = elm.getAttribute('endNode'); |
|
69 if (endNode == null) |
|
70 endNode = startNode; |
|
71 else |
|
72 endNode = getTextNode(elm.childNodes[endNode]) |
|
73 var end = elm.getAttribute('end'); |
|
74 if (end == null) end = endNode.textContent.length; |
|
75 if (startNode==endNode && start > end) return; |
|
76 if (startNode==null) return; |
|
77 range.setStart(startNode, start); |
|
78 range.setEnd(endNode, end); |
|
79 sel.addRange(range); |
|
80 } catch (e) { |
|
81 alert(e+'\n'+elm.id+'\n'+t) |
|
82 } |
|
83 } |
|
84 function selectText() { |
|
85 var divs = document.getElementsByTagName('div'); |
|
86 for (i = 0; i < divs.length; ++i) { |
|
87 addRange(divs[i]); |
|
88 } |
|
89 document.body.offsetHeight; |
|
90 setTimeout(function(){document.documentElement.removeAttribute('class')},2000); |
|
91 } |
|
92 </script> |
|
93 </head><body onload="selectText();"> |
|
94 |
|
95 |
|
96 <!-- LTR overflow:hidden --> |
|
97 <div contenteditable="true" spellcheck="true" class="test ltr hidden">Mispe|led word</div> |
|
98 <span style="display:block;width:15em"><div contenteditable="true" spellcheck="true" class="test ltr hidden" style="width:auto; float:right; font-family:TestEllipsisFallback; text-indent:-1em; " start=0 end=9><x>M ispeled word</x></div></span><br clear="all"> |
|
99 <div contenteditable="true" spellcheck="true" class="test ltr hidden"><span class="rlo">Mispelled word</span></div> |
|
100 <div contenteditable="true" spellcheck="true" class="test ltr hidden"><span class="rlo">Mispelled</span><span class="rlo"> word</span></div> |
|
101 <div contenteditable="true" spellcheck="true" class="test ltr hidden"><span class="rlo">Mis</span><span class="rlo">pelled word</div> |
|
102 <div contenteditable="true" spellcheck="true" class="test ltr hidden" endNode="1" style="text-indent:-0.2em"><span>Mis</span><span>pe|led</span><span> word</span></div> |
|
103 |
|
104 <!-- RTL overflow:hidden --> |
|
105 <div contenteditable="true" spellcheck="true" class="test rtl hidden">Mispelled word</div> |
|
106 <div contenteditable="true" spellcheck="true" class="test rtl hidden" end="2"><span class="lro">Mispelled word</span></div> |
|
107 <div contenteditable="true" spellcheck="true" class="test rtl hidden"><span class="lro">Mispelled</span><span class="rlo"> word</span></div> |
|
108 <div contenteditable="true" spellcheck="true" class="test rtl hidden"><span class="rlo">Mis</span><span class="rlo">pelled word</div> |
|
109 <div contenteditable="true" spellcheck="true" class="test rtl hidden"><span class="rlo">Mis</span><span class="rlo">pelled word</div> |
|
110 <div contenteditable="true" spellcheck="true" class="test rtl hidden"><span class="rlo" style="margin-right:-0.2em">Mis</span><span class="rlo">pelled</span><span class="rlo"> word</span></div> |
|
111 |
|
112 </body></html> |