diff options
author | mjs <mjs@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2007-03-09 02:12:43 +0000 |
---|---|---|
committer | mjs <mjs@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2007-03-09 02:12:43 +0000 |
commit | 925f06aa519a5b9f02f6b19328346f2d97510abd (patch) | |
tree | d21a7ce5757f283d9a9027f145c08930a7495ff5 | |
parent | dbd6ced54baa1919a712fa6fac3bc16caba4f5b2 (diff) | |
download | chromium_src-925f06aa519a5b9f02f6b19328346f2d97510abd.zip chromium_src-925f06aa519a5b9f02f6b19328346f2d97510abd.tar.gz chromium_src-925f06aa519a5b9f02f6b19328346f2d97510abd.tar.bz2 |
LayoutTests:
Reviewed by Adele.
<rdar://problem/4646563> REGRESSION: Unable to send text message from Verizon text message website: vtext.com (12588)
http://bugs.webkit.org/show_bug.cgi?id=12588
Carefully revised which focus operations restore previous selection, which clear it, and which
select the whole control contents, these test cases cover every focus call I could find.
* fast/forms/focus-selection-input-expected.txt: Added.
* fast/forms/focus-selection-input.html: Added.
* fast/forms/focus-selection-textarea-expected.txt: Added.
* fast/forms/focus-selection-textarea.html: Added.
* fast/forms/onselect-textfield-expected.txt:
WebCore:
Reviewed by Adele.
<rdar://problem/4646563> REGRESSION: Unable to send text message from Verizon text message website: vtext.com (12588)
http://bugs.webkit.org/show_bug.cgi?id=12588
Carefully revised which focus operations restore previous selection, which clear it, and which
select the whole control contents.
Tests:
fast/forms/focus-selection-input.html
fast/forms/focus-selection-textarea.html
* dom/Element.cpp:
(WebCore::Element::focus):
* dom/Element.h:
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::focus):
(WebCore::HTMLInputElement::accessKeyAction):
* html/HTMLInputElement.h:
* html/HTMLLabelElement.cpp:
(WebCore::HTMLLabelElement::focus):
(WebCore::HTMLLabelElement::accessKeyAction):
* html/HTMLLabelElement.h:
* html/HTMLLegendElement.cpp:
(WebCore::HTMLLegendElement::focus):
* html/HTMLLegendElement.h:
* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::focus):
* html/HTMLTextAreaElement.h:
* page/FocusController.cpp:
(WebCore::FocusController::advanceFocus):
git-svn-id: svn://svn.chromium.org/blink/trunk@20072 bbb929c8-8fbe-4397-9dbb-9b2b20218538
18 files changed, 614 insertions, 25 deletions
diff --git a/third_party/WebKit/LayoutTests/ChangeLog b/third_party/WebKit/LayoutTests/ChangeLog index 7b58ee4..fcd5bba 100644 --- a/third_party/WebKit/LayoutTests/ChangeLog +++ b/third_party/WebKit/LayoutTests/ChangeLog @@ -1,3 +1,19 @@ +2007-03-08 Maciej Stachowiak <mjs@apple.com> + + Reviewed by Adele. + + <rdar://problem/4646563> REGRESSION: Unable to send text message from Verizon text message website: vtext.com (12588) + http://bugs.webkit.org/show_bug.cgi?id=12588 + + Carefully revised which focus operations restore previous selection, which clear it, and which + select the whole control contents, these test cases cover every focus call I could find. + + * fast/forms/focus-selection-input-expected.txt: Added. + * fast/forms/focus-selection-input.html: Added. + * fast/forms/focus-selection-textarea-expected.txt: Added. + * fast/forms/focus-selection-textarea.html: Added. + * fast/forms/onselect-textfield-expected.txt: + 2007-03-08 Justin Garcia <justin.garcia@apple.com> Reviewed by harrison diff --git a/third_party/WebKit/LayoutTests/fast/forms/focus-selection-input-expected.txt b/third_party/WebKit/LayoutTests/fast/forms/focus-selection-input-expected.txt new file mode 100644 index 0000000..5cb831b --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/forms/focus-selection-input-expected.txt @@ -0,0 +1,80 @@ +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of #text > DIV to 0 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of #text > LABEL > BODY > HTML > #document to 5 of #text > LABEL > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification +<input type="text"> focus selection + +This test checks whether the selection is restored, cleared, or set to the full range when using different ways to focus a text field. These results all match Mozilla, except test 6, which selects the whole field contents to match all other cases of keyboard focus. When running manually, please follow the steps below. In the test harness, the test runs automatically. + +1) Hit tab, the whole phrase "SUCCESS and SUCCESS" should be selected: +2) Hit Ctrl-J, the whole phrase "SUCCESS and SUCCESS" should be selected: +3) , only the word "SUCCESS" should be selected: +4) Click in the input field, nothing should be selected: +5) Click this label, only the word "SUCCESS" should be selected: +6) Hit Ctrl-U, the whole phrase "SUCCESS and SUCCESS" should be selected: +7) , only the word "SUCCESS" should be selected: +8) , the whole phrase "SUCCESS and SUCCESS" should be selected: + + +9) Hit Ctrl-I, the whole phrase "SUCCESS and SUCCESS" should be selected: + + +PASS first.selectionStart is 12 +PASS first.selectionEnd is 19 +PASS first.selectionStart is 0 +PASS first.selectionEnd is 19 +PASS second.selectionStart is 11 +PASS second.selectionEnd is 18 +PASS second.selectionStart is 11 +PASS second.selectionEnd is 18 +PASS third.selectionStart is 11 +PASS third.selectionEnd is 18 +PASS third.selectionStart is 11 +PASS third.selectionEnd is 18 +PASS fourth.selectionStart is 12 +PASS fourth.selectionEnd is 19 +PASS fourth.selectionStart is 0 +PASS fourth.selectionEnd is 0 +PASS fifth.selectionStart is 11 +PASS fifth.selectionEnd is 18 +PASS fifth.selectionStart is 11 +PASS fifth.selectionEnd is 18 +PASS sixth.selectionStart is 12 +PASS sixth.selectionEnd is 19 +PASS sixth.selectionStart is 0 +PASS sixth.selectionEnd is 19 +PASS seventh.selectionStart is 11 +PASS seventh.selectionEnd is 18 +PASS seventh.selectionStart is 11 +PASS seventh.selectionEnd is 18 +PASS eighth.selectionStart is 12 +PASS eighth.selectionEnd is 19 +PASS eighth.selectionStart is 0 +PASS eighth.selectionEnd is 19 +PASS ninth.selectionStart is 12 +PASS ninth.selectionEnd is 19 +PASS ninth.selectionStart is 0 +PASS ninth.selectionEnd is 19 + diff --git a/third_party/WebKit/LayoutTests/fast/forms/focus-selection-input.html b/third_party/WebKit/LayoutTests/fast/forms/focus-selection-input.html new file mode 100644 index 0000000..0272864 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/forms/focus-selection-input.html @@ -0,0 +1,193 @@ +<head> +<link href="js-test-style.css"> +</head> +<body onload="runTest()"> +<script src="../js/resources/js-test-pre.js"></script> + +<script> +function runTest() +{ + if (!window.layoutTestController) + return; + + layoutTestController.dumpEditingCallbacks(); + layoutTestController.dumpAsText(); + + shouldBe("first.selectionStart", "12"); + shouldBe("first.selectionEnd", "19"); + eventSender.keyDown("\t"); + shouldBe("first.selectionStart", "0"); + shouldBe("first.selectionEnd", "19"); + + shouldBe("second.selectionStart", "11"); + shouldBe("second.selectionEnd", "18"); + eventSender.keyDown("J", ["ctrlKey"]); + shouldBe("second.selectionStart", "11"); + shouldBe("second.selectionEnd", "18"); + + shouldBe("third.selectionStart", "11"); + shouldBe("third.selectionEnd", "18"); + third.focus(); + shouldBe("third.selectionStart", "11"); + shouldBe("third.selectionEnd", "18"); + + shouldBe("fourth.selectionStart", "12"); + shouldBe("fourth.selectionEnd", "19"); + eventSender.mouseMoveTo(fourth.offsetLeft + 4, fourth.offsetTop + 4); + eventSender.mouseClick(); + shouldBe("fourth.selectionStart", "0"); + shouldBe("fourth.selectionEnd", "0"); + + shouldBe("fifth.selectionStart", "11"); + shouldBe("fifth.selectionEnd", "18"); + var fifthLabel = document.getElementById("fifthLabel"); + eventSender.mouseMoveTo(fifthLabel.offsetLeft + 4, fifthLabel.offsetTop + 4); + eventSender.mouseClick(); + shouldBe("fifth.selectionStart", "11"); + shouldBe("fifth.selectionEnd", "18"); + + shouldBe("sixth.selectionStart", "12"); + shouldBe("sixth.selectionEnd", "19"); + eventSender.keyDown("U", ["ctrlKey"]); + shouldBe("sixth.selectionStart", "0"); + shouldBe("sixth.selectionEnd", "19"); + + shouldBe("seventh.selectionStart", "11"); + shouldBe("seventh.selectionEnd", "18"); + var seventLabel = document.getElementById("seventhLabel"); + seventhLabel.focus(); + shouldBe("seventh.selectionStart", "11"); + shouldBe("seventh.selectionEnd", "18"); + + shouldBe("eighth.selectionStart", "12"); + shouldBe("eighth.selectionEnd", "19"); + var eighthLegend = document.getElementById("eighthLegend"); + eighthLegend.focus(); + shouldBe("eighth.selectionStart", "0"); + shouldBe("eighth.selectionEnd", "19"); + + shouldBe("ninth.selectionStart", "12"); + shouldBe("ninth.selectionEnd", "19"); + eventSender.keyDown("I", ["ctrlKey"]); + shouldBe("ninth.selectionStart", "0"); + shouldBe("ninth.selectionEnd", "19"); + +} +</script> + +<h2><input type="text"> focus selection</h2> + +<p>This test checks whether the selection is restored, cleared, or set +to the full range when using different ways to focus a text field. These +results all match Mozilla, except test 6, which selects +the whole field contents to match all other cases of keyboard +focus. When running manually, please follow the steps below. In the +test harness, the test runs automatically.</p> + +1) Hit tab, the whole phrase "SUCCESS and SUCCESS" should be selected: +<input type="text" id="first" value="SUCCESS and SUCCESS"> +<script> + var first = document.getElementById("first"); + first.focus(); + first.setSelectionRange(12, 19); + first.blur(); +</script> + +<br> + +2) Hit Ctrl-J, the whole phrase "SUCCESS and SUCCESS" should be selected: +<input type="text" id="second" accesskey="j" value="SUCCESS and SUCCESS"> +<script> + var second = document.getElementById("second"); + second.focus(); + second.setSelectionRange(12, 19); + second.blur(); +</script> + +<br> + +3) <input type="button" onclick="document.getElementById('third').focus()" value="Click this button">, only the word "SUCCESS" should be selected: +<input type="text" id="third" value="FAILURE or SUCCESS"> +<script> + var third = document.getElementById("third"); + third.focus(); + third.setSelectionRange(11, 18); + third.blur(); +</script> + +<br> + +4) Click in the input field, nothing should be selected: +<input type="text" id="fourth" value="FAILURE and FAILURE"> +<script> + var fourth = document.getElementById("fourth"); + fourth.focus(); + fourth.setSelectionRange(12, 19); + fourth.blur(); +</script> + +<br> + +5) <label id="fifthLabel" for="fifth" style="color: blue">Click this label, only the word "SUCCESS" should be selected:</label> +<input type="text" id="fifth" value="FAILURE or SUCCESS"> +<script> + var second = document.getElementById("fifth"); + fifth.focus(); + fifth.setSelectionRange(11, 18); + fifth.blur(); +</script> + +<br> + +6) <label id="sixthLabel" for="sixth" accesskey="u">Hit Ctrl-U, the whole phrase "SUCCESS and SUCCESS" should be selected:</label> +<input type="text" id="sixth" value="SUCCESS and SUCCESS"> +<script> + var sixth = document.getElementById("sixth"); + sixth.focus(); + sixth.setSelectionRange(12, 19); + sixth.blur(); +</script> + +<br> + +7) <input type="button" onclick="document.getElementById('seventhLabel').focus()" value="Click this button"><label id="seventhLabel" for="seventh">, only the word "SUCCESS" should be selected:</label> +<input type="text" id="seventh" value="FAILURE or SUCCESS"> +<script> + var seventh = document.getElementById("seventh"); + seventh.focus(); + seventh.setSelectionRange(11, 18); + seventh.blur(); +</script> + +<br> + +8) <input type="button" onclick="document.getElementById('eighthLegend').focus()" value="Click this button"> +<fieldset> +<legend id="eighthLegend">, the whole phrase "SUCCESS and SUCCESS" should be selected:</legend> +<input type="text" id="eighth" value="SUCCESS and SUCCESS"> +<script> + var eighth = document.getElementById("eighth"); + eighth.focus(); + eighth.setSelectionRange(12, 19); + eighth.blur(); +</script> +</fieldset> +<br> + + +9) <fieldset> +<legend id="eighthLegend" accesskey="i">Hit Ctrl-I, the whole phrase "SUCCESS and SUCCESS" should be selected:</legend> +<input type="text" id="ninth" value="SUCCESS and SUCCESS"> +<script> + var ninth = document.getElementById("ninth"); + ninth.focus(); + ninth.setSelectionRange(12, 19); + ninth.blur(); +</script> +</fieldset> +<br> + +<p id="description"></p> +<div id="console"></div> + +</body> diff --git a/third_party/WebKit/LayoutTests/fast/forms/focus-selection-textarea-expected.txt b/third_party/WebKit/LayoutTests/fast/forms/focus-selection-textarea-expected.txt new file mode 100644 index 0000000..fa4d9eb --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/forms/focus-selection-textarea-expected.txt @@ -0,0 +1,73 @@ +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of #text > DIV to 0 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of #text > LABEL > BODY > HTML > #document to 5 of #text > LABEL > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +<textarea> focus selection + +This test checks whether the selection is restored, cleared, or set to the full range when using different ways to focus a text area. These results all match Mozilla. When running manually, please follow the steps below. In the test harness, the test runs automatically. + +1) Hit tab, only the word "SUCCESS" should be selected: +2) Hit Ctrl-J, only the word "SUCCESS" should be selected: +3) , only the word "SUCCESS" should be selected: +4) Click in the input field, nothing should be selected: +5) Click this label, only the word "SUCCESS" should be selected: +6) Hit Ctrl-U, only the word "SUCCESS" should be selected: +7) , only the word "SUCCESS" should be selected: +8) , only the word "SUCCESS" should be selected: + + +9) Hit Ctrl-I, only the word "SUCCESS" should be selected: + + +PASS first.selectionStart is 11 +PASS first.selectionEnd is 18 +PASS first.selectionStart is 11 +PASS first.selectionEnd is 18 +PASS second.selectionStart is 11 +PASS second.selectionEnd is 18 +PASS second.selectionStart is 11 +PASS second.selectionEnd is 18 +PASS third.selectionStart is 11 +PASS third.selectionEnd is 18 +PASS third.selectionStart is 11 +PASS third.selectionEnd is 18 +PASS fourth.selectionStart is 11 +PASS fourth.selectionEnd is 18 +PASS fourth.selectionStart is 0 +PASS fourth.selectionEnd is 0 +PASS fifth.selectionStart is 11 +PASS fifth.selectionEnd is 18 +PASS fifth.selectionStart is 11 +PASS fifth.selectionEnd is 18 +PASS sixth.selectionStart is 11 +PASS sixth.selectionEnd is 18 +PASS sixth.selectionStart is 11 +PASS sixth.selectionEnd is 18 +PASS seventh.selectionStart is 11 +PASS seventh.selectionEnd is 18 +PASS seventh.selectionStart is 11 +PASS seventh.selectionEnd is 18 +PASS eighth.selectionStart is 11 +PASS eighth.selectionEnd is 18 +PASS eighth.selectionStart is 11 +PASS eighth.selectionEnd is 18 +PASS ninth.selectionStart is 11 +PASS ninth.selectionEnd is 18 +PASS ninth.selectionStart is 11 +PASS ninth.selectionEnd is 18 + diff --git a/third_party/WebKit/LayoutTests/fast/forms/focus-selection-textarea.html b/third_party/WebKit/LayoutTests/fast/forms/focus-selection-textarea.html new file mode 100644 index 0000000..cf2beb0 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/forms/focus-selection-textarea.html @@ -0,0 +1,192 @@ +<head> +<link href="js-test-style.css"> +</head> +<body onload="runTest()"> +<script src="../js/resources/js-test-pre.js"></script> + +<script> +function runTest() +{ + if (!window.layoutTestController) + return; + + layoutTestController.dumpEditingCallbacks(); + layoutTestController.dumpAsText(); + + shouldBe("first.selectionStart", "11"); + shouldBe("first.selectionEnd", "18"); + eventSender.keyDown("\t"); + shouldBe("first.selectionStart", "11"); + shouldBe("first.selectionEnd", "18"); + + shouldBe("second.selectionStart", "11"); + shouldBe("second.selectionEnd", "18"); + eventSender.keyDown("J", ["ctrlKey"]); + shouldBe("second.selectionStart", "11"); + shouldBe("second.selectionEnd", "18"); + + shouldBe("third.selectionStart", "11"); + shouldBe("third.selectionEnd", "18"); + third.focus(); + shouldBe("third.selectionStart", "11"); + shouldBe("third.selectionEnd", "18"); + + shouldBe("fourth.selectionStart", "11"); + shouldBe("fourth.selectionEnd", "18"); + eventSender.mouseMoveTo(fourth.offsetLeft + 4, fourth.offsetTop + 4); + eventSender.mouseClick(); + shouldBe("fourth.selectionStart", "0"); + shouldBe("fourth.selectionEnd", "0"); + + shouldBe("fifth.selectionStart", "11"); + shouldBe("fifth.selectionEnd", "18"); + var fifthLabel = document.getElementById("fifthLabel"); + eventSender.mouseMoveTo(fifthLabel.offsetLeft + 4, fifthLabel.offsetTop + 4); + eventSender.mouseClick(); + shouldBe("fifth.selectionStart", "11"); + shouldBe("fifth.selectionEnd", "18"); + + shouldBe("sixth.selectionStart", "11"); + shouldBe("sixth.selectionEnd", "18"); + eventSender.keyDown("U", ["ctrlKey"]); + shouldBe("sixth.selectionStart", "11"); + shouldBe("sixth.selectionEnd", "18"); + + shouldBe("seventh.selectionStart", "11"); + shouldBe("seventh.selectionEnd", "18"); + var seventLabel = document.getElementById("seventhLabel"); + seventhLabel.focus(); + shouldBe("seventh.selectionStart", "11"); + shouldBe("seventh.selectionEnd", "18"); + + shouldBe("eighth.selectionStart", "11"); + shouldBe("eighth.selectionEnd", "18"); + var eighthLegend = document.getElementById("eighthLegend"); + eighthLegend.focus(); + shouldBe("eighth.selectionStart", "11"); + shouldBe("eighth.selectionEnd", "18"); + + shouldBe("ninth.selectionStart", "11"); + shouldBe("ninth.selectionEnd", "18"); + eventSender.keyDown("I", ["ctrlKey"]); + shouldBe("ninth.selectionStart", "11"); + shouldBe("ninth.selectionEnd", "18"); + +} +</script> + +<h2><textarea> focus selection</h2> + +<p>This test checks whether the selection is restored, cleared, or set +to the full range when using different ways to focus a text +area. These results all match Mozilla. When running manually, please +follow the steps below. In the test harness, the test runs +automatically.</p> + +1) Hit tab, only the word "SUCCESS" should be selected: +<textarea id="first">FAILURE or SUCCESS</textarea> +<script> + var first = document.getElementById("first"); + first.focus(); + first.setSelectionRange(11, 18); + first.blur(); +</script> + +<br> + +2) Hit Ctrl-J, only the word "SUCCESS" should be selected: +<textarea id="second" accesskey="j">FAILURE or SUCCESS</textarea> +<script> + var second = document.getElementById("second"); + second.focus(); + second.setSelectionRange(11, 18); + second.blur(); +</script> + +<br> + +3) <input type="button" onclick="document.getElementById('third').focus()" value="Click this button">, only the word "SUCCESS" should be selected: +<textarea id="third">FAILURE or SUCCESS</textarea> +<script> + var third = document.getElementById("third"); + third.focus(); + third.setSelectionRange(11, 18); + third.blur(); +</script> + +<br> + +4) Click in the input field, nothing should be selected: +<textarea id="fourth">FAILURE and FAILURE</textarea> +<script> + var fourth = document.getElementById("fourth"); + fourth.focus(); + fourth.setSelectionRange(11, 18); + fourth.blur(); +</script> + +<br> + +5) <label id="fifthLabel" for="fifth" style="color: blue">Click this label, only the word "SUCCESS" should be selected:</label> +<textarea id="fifth">FAILURE or SUCCESS</textarea> +<script> + var second = document.getElementById("fifth"); + fifth.focus(); + fifth.setSelectionRange(11, 18); + fifth.blur(); +</script> + +<br> + +6) <label id="sixthLabel" for="sixth" accesskey="u">Hit Ctrl-U, only the word "SUCCESS" should be selected:</label> +<textarea id="sixth">FAILURE or SUCCESS</textarea> +<script> + var sixth = document.getElementById("sixth"); + sixth.focus(); + sixth.setSelectionRange(11, 18); + sixth.blur(); +</script> + +<br> + +7) <input type="button" onclick="document.getElementById('seventhLabel').focus()" value="Click this button"><label id="seventhLabel" for="seventh">, only the word "SUCCESS" should be selected:</label> +<textarea id="seventh">FAILURE or SUCCESS</textarea> +<script> + var seventh = document.getElementById("seventh"); + seventh.focus(); + seventh.setSelectionRange(11, 18); + seventh.blur(); +</script> + +<br> + +8) <input type="button" onclick="document.getElementById('eighthLegend').focus()" value="Click this button"> +<fieldset> +<legend id="eighthLegend">, only the word "SUCCESS" should be selected:</legend> +<textarea id="eighth">FAILURE or SUCCESS</textarea> +<script> + var eighth = document.getElementById("eighth"); + eighth.focus(); + eighth.setSelectionRange(11, 18); + eighth.blur(); +</script> +</fieldset> +<br> + + +9) <fieldset> +<legend id="eighthLegend" accesskey="i">Hit Ctrl-I, only the word "SUCCESS" should be selected:</legend> +<textarea id="ninth">FAILURE or SUCCESS</textarea> +<script> + var ninth = document.getElementById("ninth"); + ninth.focus(); + ninth.setSelectionRange(11, 18); + ninth.blur(); +</script> +</fieldset> +<br> + +<p id="description"></p> +<div id="console"></div> + +</body>
\ No newline at end of file diff --git a/third_party/WebKit/LayoutTests/fast/forms/onselect-textfield-expected.txt b/third_party/WebKit/LayoutTests/fast/forms/onselect-textfield-expected.txt index a3dfc91..13103db 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/onselect-textfield-expected.txt +++ b/third_party/WebKit/LayoutTests/fast/forms/onselect-textfield-expected.txt @@ -16,5 +16,5 @@ Calling blur on text field After blur: text field selection start: 6 end: 10 Calling focus on text field -After focus: text field selection start: 0 end: 10 +After focus: text field selection start: 6 end: 10 diff --git a/third_party/WebKit/WebCore/ChangeLog b/third_party/WebKit/WebCore/ChangeLog index 5accaa2..0934a17 100644 --- a/third_party/WebKit/WebCore/ChangeLog +++ b/third_party/WebKit/WebCore/ChangeLog @@ -1,3 +1,37 @@ +2007-03-08 Maciej Stachowiak <mjs@apple.com> + + Reviewed by Adele. + + <rdar://problem/4646563> REGRESSION: Unable to send text message from Verizon text message website: vtext.com (12588) + http://bugs.webkit.org/show_bug.cgi?id=12588 + + Carefully revised which focus operations restore previous selection, which clear it, and which + select the whole control contents. + + Tests: + fast/forms/focus-selection-input.html + fast/forms/focus-selection-textarea.html + + * dom/Element.cpp: + (WebCore::Element::focus): + * dom/Element.h: + * html/HTMLInputElement.cpp: + (WebCore::HTMLInputElement::focus): + (WebCore::HTMLInputElement::accessKeyAction): + * html/HTMLInputElement.h: + * html/HTMLLabelElement.cpp: + (WebCore::HTMLLabelElement::focus): + (WebCore::HTMLLabelElement::accessKeyAction): + * html/HTMLLabelElement.h: + * html/HTMLLegendElement.cpp: + (WebCore::HTMLLegendElement::focus): + * html/HTMLLegendElement.h: + * html/HTMLTextAreaElement.cpp: + (WebCore::HTMLTextAreaElement::focus): + * html/HTMLTextAreaElement.h: + * page/FocusController.cpp: + (WebCore::FocusController::advanceFocus): + 2007-03-08 Justin Garcia <justin.garcia@apple.com> Reviewed by harrison diff --git a/third_party/WebKit/WebCore/dom/Element.cpp b/third_party/WebKit/WebCore/dom/Element.cpp index b1b32a5..fa0ea81 100644 --- a/third_party/WebKit/WebCore/dom/Element.cpp +++ b/third_party/WebKit/WebCore/dom/Element.cpp @@ -889,7 +889,7 @@ CSSStyleDeclaration *Element::style() return 0; } -void Element::focus() +void Element::focus(bool restorePreviousSelection) { Document* doc = document(); doc->updateLayout(); @@ -905,7 +905,7 @@ void Element::focus() return; } - updateFocusAppearance(); + updateFocusAppearance(restorePreviousSelection); } void Element::updateFocusAppearance(bool restorePreviousSelection) diff --git a/third_party/WebKit/WebCore/dom/Element.h b/third_party/WebKit/WebCore/dom/Element.h index 01a3edd..ea80926 100644 --- a/third_party/WebKit/WebCore/dom/Element.h +++ b/third_party/WebKit/WebCore/dom/Element.h @@ -158,7 +158,7 @@ public: virtual bool isURLAttribute(Attribute *attr) const; virtual String target() const { return String(); } - virtual void focus(); + virtual void focus(bool restorePreviousSelection = true); virtual void updateFocusAppearance(bool restorePreviousSelection = false); void blur(); bool needsFocusAppearanceUpdate() const { return m_needsFocusAppearanceUpdate; } diff --git a/third_party/WebKit/WebCore/html/HTMLInputElement.cpp b/third_party/WebKit/WebCore/html/HTMLInputElement.cpp index e2bcb9a..fb949fe 100644 --- a/third_party/WebKit/WebCore/html/HTMLInputElement.cpp +++ b/third_party/WebKit/WebCore/html/HTMLInputElement.cpp @@ -182,7 +182,7 @@ bool HTMLInputElement::isMouseFocusable() const return HTMLGenericFormElement::isMouseFocusable(); } -void HTMLInputElement::focus() +void HTMLInputElement::focus(bool restorePreviousSelection) { if (isTextField()) { Document* doc = document(); @@ -198,10 +198,10 @@ void HTMLInputElement::focus() setNeedsFocusAppearanceUpdate(true); return; } - updateFocusAppearance(); + updateFocusAppearance(restorePreviousSelection); return; } - HTMLGenericFormElement::focus(); + HTMLGenericFormElement::focus(restorePreviousSelection); } void HTMLInputElement::updateFocusAppearance(bool restorePreviousSelection) @@ -534,8 +534,7 @@ void HTMLInputElement::accessKeyAction(bool sendToAnyElement) case RANGE: case RESET: case SUBMIT: - // focus - focus(); + focus(false); // send the mouse button events iff the caller specified sendToAnyElement dispatchSimulatedClick(0, sendToAnyElement); break; @@ -546,7 +545,8 @@ void HTMLInputElement::accessKeyAction(bool sendToAnyElement) case PASSWORD: case SEARCH: case TEXT: - focus(); + // should never restore previous selection here + focus(false); break; } } diff --git a/third_party/WebKit/WebCore/html/HTMLInputElement.h b/third_party/WebKit/WebCore/html/HTMLInputElement.h index 9f4449c..9170fd1 100644 --- a/third_party/WebKit/WebCore/html/HTMLInputElement.h +++ b/third_party/WebKit/WebCore/html/HTMLInputElement.h @@ -61,7 +61,7 @@ public: virtual bool isKeyboardFocusable(KeyboardEvent*) const; virtual bool isMouseFocusable() const; virtual bool isEnumeratable() const { return inputType() != IMAGE; } - virtual void focus(); + virtual void focus(bool restorePreviousSelection = true); virtual void dispatchFocusEvent(); virtual void dispatchBlurEvent(); virtual void updateFocusAppearance(bool restorePreviousSelection = false); diff --git a/third_party/WebKit/WebCore/html/HTMLLabelElement.cpp b/third_party/WebKit/WebCore/html/HTMLLabelElement.cpp index aa1f4f1..34a2205 100644 --- a/third_party/WebKit/WebCore/html/HTMLLabelElement.cpp +++ b/third_party/WebKit/WebCore/html/HTMLLabelElement.cpp @@ -26,12 +26,12 @@ #include "config.h" #include "HTMLLabelElement.h" -#include "HTMLFormElement.h" -#include "HTMLNames.h" -#include "EventNames.h" -#include "Event.h" #include "Document.h" +#include "Event.h" +#include "EventNames.h" +#include "HTMLFormElement.h" +#include "HTMLNames.h" namespace WebCore { @@ -130,16 +130,16 @@ void HTMLLabelElement::defaultEventHandler(Event* evt) HTMLElement::defaultEventHandler(evt); } -void HTMLLabelElement::focus() +void HTMLLabelElement::focus(bool) { + // to match other browsers, always restore previous selection if (Element* element = formElement()) element->focus(); } void HTMLLabelElement::accessKeyAction(bool sendToAnyElement) { - Element *element = formElement(); - if (element) + if (Element* element = formElement()) element->accessKeyAction(sendToAnyElement); } diff --git a/third_party/WebKit/WebCore/html/HTMLLabelElement.h b/third_party/WebKit/WebCore/html/HTMLLabelElement.h index 05c62ba..35d7b3a 100644 --- a/third_party/WebKit/WebCore/html/HTMLLabelElement.h +++ b/third_party/WebKit/WebCore/html/HTMLLabelElement.h @@ -64,7 +64,7 @@ public: String htmlFor() const; void setHtmlFor(const String &); - void focus(); + void focus(bool restorePreviousSelection = true); private: String m_formElementID; diff --git a/third_party/WebKit/WebCore/html/HTMLLegendElement.cpp b/third_party/WebKit/WebCore/html/HTMLLegendElement.cpp index bffd3be..285b4af 100644 --- a/third_party/WebKit/WebCore/html/HTMLLegendElement.cpp +++ b/third_party/WebKit/WebCore/html/HTMLLegendElement.cpp @@ -105,10 +105,11 @@ Element *HTMLLegendElement::formElement() return 0; } -void HTMLLegendElement::focus() +void HTMLLegendElement::focus(bool) { + // to match other browsers, never restore previous selection if (Element *element = formElement()) - element->focus(); + element->focus(false); } void HTMLLegendElement::accessKeyAction(bool sendToAnyElement) diff --git a/third_party/WebKit/WebCore/html/HTMLLegendElement.h b/third_party/WebKit/WebCore/html/HTMLLegendElement.h index b6b4489..06b7a11 100644 --- a/third_party/WebKit/WebCore/html/HTMLLegendElement.h +++ b/third_party/WebKit/WebCore/html/HTMLLegendElement.h @@ -51,7 +51,7 @@ public: String align() const; void setAlign(const String &); - void focus(); + void focus(bool restorePreviousSelection = true); }; } //namespace diff --git a/third_party/WebKit/WebCore/html/HTMLTextAreaElement.cpp b/third_party/WebKit/WebCore/html/HTMLTextAreaElement.cpp index 49fa14b..b1a5741 100644 --- a/third_party/WebKit/WebCore/html/HTMLTextAreaElement.cpp +++ b/third_party/WebKit/WebCore/html/HTMLTextAreaElement.cpp @@ -200,7 +200,7 @@ bool HTMLTextAreaElement::isMouseFocusable() const return HTMLGenericFormElement::isFocusable(); } -void HTMLTextAreaElement::focus() +void HTMLTextAreaElement::focus(bool) { Document* doc = document(); if (doc->focusedNode() == this) diff --git a/third_party/WebKit/WebCore/html/HTMLTextAreaElement.h b/third_party/WebKit/WebCore/html/HTMLTextAreaElement.h index 930df24..30c7197 100644 --- a/third_party/WebKit/WebCore/html/HTMLTextAreaElement.h +++ b/third_party/WebKit/WebCore/html/HTMLTextAreaElement.h @@ -72,7 +72,7 @@ public: virtual void defaultEventHandler(Event*); virtual bool isMouseFocusable() const; virtual bool isKeyboardFocusable(KeyboardEvent*) const; - virtual void focus(); + virtual void focus(bool restorePreviousSelection = true); virtual void updateFocusAppearance(bool restorePreviousSelection = true); String value() const; diff --git a/third_party/WebKit/WebCore/page/FocusController.cpp b/third_party/WebKit/WebCore/page/FocusController.cpp index bd1f8a2..4924ae3 100644 --- a/third_party/WebKit/WebCore/page/FocusController.cpp +++ b/third_party/WebKit/WebCore/page/FocusController.cpp @@ -203,7 +203,7 @@ bool FocusController::advanceFocus(FocusDirection direction, KeyboardEvent* even if (newDocument) setFocusedFrame(newDocument->frame()); - static_cast<Element*>(node)->focus(); + static_cast<Element*>(node)->focus(false); return true; } |