3 Any copyright is dedicated to the Public Domain.
4 http://creativecommons.org/licenses/publicdomain/
6 Test: Selected text, background, decorations
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">
13 font-family: DejaVuSansMono
;
14 src: url
(../fonts/DejaVuSansMono.woff);
17 font-family: TestEllipsisFallback
;
18 src: url
(TestEllipsisFallback.woff);
21 color:black
; background-color:white
; font-size:16px; padding:0; margin:0; font-family:DejaVuSansMono
;
26 text-overflow:ellipsis ellipsis
;
41 unicode-bidi: bidi-override
; direction: rtl
;
44 unicode-bidi: bidi-override
; direction: ltr
;
49 x
{font-family:DejaVuSansMono
;}
52 function getTextNode(elm
) {
53 if (elm
.nodeType
!= 3)
54 return getTextNode(elm
.firstChild
);
57 function addRange(elm
) {
59 var sel
= window
.getSelection();
60 var range
= document
.createRange();
61 var startNode
= elm
.getAttribute('startNode');
62 if (startNode
== null)
63 startNode
= getTextNode(elm
);
65 startNode
= getTextNode(elm
.childNodes
[startNode
])
66 var start
= elm
.getAttribute('start');
67 if (start
== null) start
= 2;
68 var endNode
= elm
.getAttribute('endNode');
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
);
81 alert(e
+'\n'+elm
.id
+'\n'+t
)
84 function selectText() {
85 // For putting selection ranges to multiple editing hosts, we need to put
86 // a range outside all editable elements first, then, selection's ancestor
87 // limiter won't be set to an editing host.
88 getSelection().collapse(document
.body
, document
.body
.childNodes
.length
);
89 var divs
= document
.getElementsByTagName('div');
90 for (i
= 0; i
< divs
.length
; ++i
) {
93 document
.body
.offsetHeight
;
94 setTimeout(function(){document
.documentElement
.removeAttribute('class')},2000);
97 </head><body onload=
"selectText();">
100 <!-- LTR overflow:hidden -->
101 <div contenteditable=
"true" spellcheck=
"true" class=
"test ltr hidden">Mispe|led word
</div>
102 <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">
103 <div contenteditable=
"true" spellcheck=
"true" class=
"test ltr hidden"><span class=
"rlo">Mispelled word
</span></div>
104 <div contenteditable=
"true" spellcheck=
"true" class=
"test ltr hidden"><span class=
"rlo">Mispelled
</span><span class=
"rlo"> word
</span></div>
105 <div contenteditable=
"true" spellcheck=
"true" class=
"test ltr hidden"><span class=
"rlo">Mis
</span><span class=
"rlo">pelled word
</div>
106 <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>
108 <!-- RTL overflow:hidden -->
109 <div contenteditable=
"true" spellcheck=
"true" class=
"test rtl hidden">Mispelled word
</div>
110 <div contenteditable=
"true" spellcheck=
"true" class=
"test rtl hidden" end=
"2"><span class=
"lro">Mispelled word
</span></div>
111 <div contenteditable=
"true" spellcheck=
"true" class=
"test rtl hidden"><span class=
"lro">Mispelled
</span><span class=
"rlo"> word
</span></div>
112 <div contenteditable=
"true" spellcheck=
"true" class=
"test rtl hidden"><span class=
"rlo">Mis
</span><span class=
"rlo">pelled word
</div>
113 <div contenteditable=
"true" spellcheck=
"true" class=
"test rtl hidden"><span class=
"rlo">Mis
</span><span class=
"rlo">pelled word
</div>
114 <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>