+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
--- /dev/null
+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
+
--- /dev/null
+<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>
--- /dev/null
+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
+
--- /dev/null
+<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
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
+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
return 0;
}
-void Element::focus()
+void Element::focus(bool restorePreviousSelection)
{
Document* doc = document();
doc->updateLayout();
return;
}
- updateFocusAppearance();
+ updateFocusAppearance(restorePreviousSelection);
}
void Element::updateFocusAppearance(bool restorePreviousSelection)
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; }
return HTMLGenericFormElement::isMouseFocusable();
}
-void HTMLInputElement::focus()
+void HTMLInputElement::focus(bool restorePreviousSelection)
{
if (isTextField()) {
Document* doc = document();
setNeedsFocusAppearanceUpdate(true);
return;
}
- updateFocusAppearance();
+ updateFocusAppearance(restorePreviousSelection);
return;
}
- HTMLGenericFormElement::focus();
+ HTMLGenericFormElement::focus(restorePreviousSelection);
}
void HTMLInputElement::updateFocusAppearance(bool restorePreviousSelection)
case RANGE:
case RESET:
case SUBMIT:
- // focus
- focus();
+ focus(false);
// send the mouse button events iff the caller specified sendToAnyElement
dispatchSimulatedClick(0, sendToAnyElement);
break;
case PASSWORD:
case SEARCH:
case TEXT:
- focus();
+ // should never restore previous selection here
+ focus(false);
break;
}
}
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);
#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 {
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);
}
String htmlFor() const;
void setHtmlFor(const String &);
- void focus();
+ void focus(bool restorePreviousSelection = true);
private:
String m_formElementID;
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)
String align() const;
void setAlign(const String &);
- void focus();
+ void focus(bool restorePreviousSelection = true);
};
} //namespace
return HTMLGenericFormElement::isFocusable();
}
-void HTMLTextAreaElement::focus()
+void HTMLTextAreaElement::focus(bool)
{
Document* doc = document();
if (doc->focusedNode() == this)
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;
if (newDocument)
setFocusedFrame(newDocument->frame());
- static_cast<Element*>(node)->focus();
+ static_cast<Element*>(node)->focus(false);
return true;
}