Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / cursor-at-editable-content-boundary.html
blob0060737dffe82de3c74cf9b09a7dfda3e32b89bc
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <style>
5 .editable {
6 border-width: 0px;
7 margin: 0px;
8 padding: 0px;
9 font-size: 10px;
11 </style>
12 <script src="../../resources/js-test.js"></script>
13 <script>
15 var succeed = true;
17 function runTest()
19 if (window.testRunner)
20 testRunner.dumpAsText();
22 // The 2nd parameter 22 is the last character in textarea with id "textarea_rtl".
23 testCaretRect("textarea_rtl", 22, "rtl", "horizontal");
24 // 6 is the last character in textarea with id "textarea_ltr".
25 testCaretRect("textarea_ltr", 6, "ltr", "horizontal");
26 // 22 is the last character in "vertical_rl" div.
27 testCaretRect("vertical_rl", 22, "rtl", "vertical");
29 if (succeed == true)
30 testPassed('');
33 function setFont(e)
35 e.style.fontFamily = "sans-serif";
36 e.style.fontSize = 10 + "px";
39 function testCaretRect(id, characterIndex, direction, writingMode)
41 var e = document.getElementById("span_" + id);
42 setFont(e);
44 var length;
45 if (writingMode == "horizontal")
46 length = e.offsetWidth;
47 else
48 length = e.offsetHeight;
50 e.style.visibility = "hidden";
52 testCaretRectInTextArea(id, length, characterIndex, direction, writingMode);
53 testCaretRectInTextArea(id + "_no_wrap", length, characterIndex, direction, writingMode);
56 function testCaretRectInTextArea(id, length, characterIndex, direction, writingMode)
58 e = document.getElementById(id);
59 if (e == null)
60 return;
62 setFont(e);
64 var originalLength = length;
65 if (id.match("_no_wrap"))
66 length = parseInt(length * 0.9);
68 if (writingMode == "horizontal")
69 e.style.width = length + "px";
70 else
71 e.style.height = length + "px";
73 e.focus();
75 if (window.textInputController) {
76 var first = caretRectForCharacter(0, writingMode);
77 var last = caretRectForCharacter(characterIndex, writingMode);
79 var caretRange;
80 if (direction == "rtl")
81 caretRange = first - last;
82 else
83 caretRange = last - first;
84 caretRange = Math.abs(caretRange);
86 if (caretRange != originalLength - 1) {
87 succeed = false;
88 --originalLength;
89 testFailed("test id: " + id + " (text width: " + originalLength + " != caretRange: " + caretRange + ")," +
90 " which means moving caret in the text, caret might be invisible or overlap with element.");
93 e.style.visibility = "hidden";
97 function caretRectForCharacter(characterIndex, writingMode)
99 var caretRect = textInputController.firstRectForCharacterRange(characterIndex, 0);
100 if (writingMode == "horizontal")
101 return caretRect[0];
102 return caretRect[1];
104 </script>
105 </head>
107 <body>
108 <!-- Following <div>/<span> is for width calculation -->
109 <div class="editable"><span id="span_textarea_rtl" class="editable" dir="rtl">&#1491;&#1490;&#1500;&#1495;&#1499; &#1490;&#1491;&#1499; &#1500;&#1495;&#1497;&#1491;&#1490;&#1499; &#1497;&#1495;&#1506;&#1491;&#1491;</span></div>
111 <p>autowrap text area with dir=rtl.
112 <textarea id="textarea_rtl" style="font-size:10px;" dir="rtl">&#1491;&#1490;&#1500;&#1495;&#1499; &#1490;&#1491;&#1499; &#1500;&#1495;&#1497;&#1491;&#1490;&#1499; &#1497;&#1495;&#1506;&#1491;&#1491;</textarea>
114 <p>nowrap text area with dir=rtl.
115 <!-- caret position overlaps with character (http://webkit.org/b/56854) -->
116 <textarea id="textarea_rtl_no_wrap" style="white-space:nowrap; font-size: 10px" dir="rtl">&#1491;&#1490;&#1500;&#1495;&#1499; &#1490;&#1491;&#1499; &#1500;&#1495;&#1497;&#1491;&#1490;&#1499; &#1497;&#1495;&#1506;&#1491;&#1491;</textarea>
118 <!-- Following <div>/<span> is for width calculation -->
119 <div class="editable"><pre class="editable"><span id="span_textarea_ltr" class="editable">www </span></pre></div>
121 <p>autowrap text area with dir=ltr.
122 <textarea id="textarea_ltr" style="font-size:10px">www </textarea>
124 <!-- Following <div>/<span> is for width calculation -->
125 <div style="-webkit-writing-mode:vertical-rl;" class="editable"><span id="span_vertical_rl" class="editable">&#1491;&#1490;&#1500;&#1495;&#1499; &#1490;&#1491;&#1499; &#1500;&#1495;&#1497;&#1491;&#1490;&#1499; &#1497;&#1495;&#1506;&#1491;&#1491;</span></div>
127 <p>vertical text.
128 <div contenteditable id="vertical_rl" style="-webkit-writing-mode:vertical-rl;" class="editable">&#1491;&#1490;&#1500;&#1495;&#1499; &#1490;&#1491;&#1499; &#1500;&#1495;&#1497;&#1491;&#1490;&#1499; &#1497;&#1495;&#1506;&#1491;&#1491;</div>
130 <ul id="console"></ul>
131 </body>
133 <script>runTest();</script>
134 </html>