Source/WebCore/ChangeLog

 12011-06-04 una sabovic <una.sabovic@palm.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 After setting text to empty string and removing children nodes selection will be set to noselection.
 6 If this is the currently focused element update the focus appearance which will restore the carret.
 7 https://bugs.webkit.org/show_bug.cgi?id=62092
 8
 9 Test: fast/dom/HTMLElement/editable-div-clear-on-keydown.html
 10
 11 * html/HTMLElement.cpp:
 12 (WebCore::HTMLElement::setInnerText):
 13
1142011-06-03 Dimitri Glazkov <dglazkov@chromium.org>
215
316 Reviewed by Darin Adler.
88115

Source/WebCore/html/HTMLElement.cpp

@@void HTMLElement::setInnerText(const Str
452452 if (!text.contains('\n') && !text.contains('\r')) {
453453 if (text.isEmpty()) {
454454 removeChildren();
 455 if (document()->focusedNode() == this)
 456 updateFocusAppearance(true);
455457 return;
456458 }
457459 replaceChildrenWithText(this, text, ec);
87961

LayoutTests/ChangeLog

 12011-06-04 una sabovic <una.sabovic@palm.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 After setting innerText to an empty string selection (caret) is lost.
 6 https://bugs.webkit.org/show_bug.cgi?id=62092
 7
 8 * fast/dom/HTMLElement/editable-div-clear-on-keydown-expected.txt: Added.
 9 * fast/dom/HTMLElement/editable-div-clear-on-keydown.html: Added.
 10
1112011-06-04 Laszlo Gombos <laszlo.1.gombos@nokia.com>
212
313 Reviewed by Andreas Kling.
88115

LayoutTests/fast/dom/HTMLElement/editable-div-clear-on-keydown-expected.txt

 1Tests behavior of code that clears the text from an editable div and focuses it on keyDown event with specific keyCode. Key to clear is 'r' for 'reset'
 2
 3The test runs only under DumpRenderTree with eventSender; if you test by hand the test result below will say FAIL.
 4
 5r
 6PASS
0

LayoutTests/fast/dom/HTMLElement/editable-div-clear-on-keydown.html

 1<html>
 2<head>
 3<script>
 4function test() {
 5 if (window.layoutTestController)
 6 layoutTestController.dumpAsText();
 7
 8 var it = document.getElementById("it");
 9 it.focus();
 10
 11 if (window.eventSender) {
 12 eventSender.keyDown("r"); // reset and focus
 13 }
 14
 15 if (it.innerText == "r")
 16 document.getElementById("result").innerHTML = "PASS";
 17 else
 18 document.getElementById("result").innerHTML = "FAIL: editable div content is '" + it.innerText + "' and it should be 'r'";
 19}
 20
 21function resetIt(event) {
 22 if (event.keyCode === 82) { //r
 23 var it = document.getElementById("it");
 24 it.innerText = '';
 25 it.focus();
 26 }
 27}
 28
 29</script>
 30</head>
 31<body onload="test()">
 32<p>Tests behavior of code that clears the text from an editable div and focuses it on keyDown event with specific keyCode. Key to clear is 'r' for 'reset'</p>
 33<p>The test runs only under DumpRenderTree with eventSender; if you test by hand the test result below will say FAIL.</p>
 34<div id="it" style="-webkit-user-modify: read-write;-webkit-user-select: text;cursor: text;" onKeyDown="resetIt(event)">text</div>
 35<p id="result">TEST NOT RUN YET</p>
 36</body>
 37</html>
0