+++ /dev/null
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<head>
-</head>
-<body>
-<p id="description">Bug 45940: A bug that a placeholder text is not cleared by the second focus.
-The first input field should not have any text.</p>
-<div>
-<input id=i1 placeholder="FAIL; This should no be visible." style="color: red;">
-<input id=i2>
-<script>
-var i1 = document.getElementById('i1');
-var i2 = document.getElementById('i2');
-i1.focus();
-i2.focus();
-i1.focus();
-</script>
-</body>
-</html>
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+</head>
+<body>
+<p id="description">Focus the field, focus away, then focus the field again.</p>
+<div>
+<input id=i1 placeholder="Placeholder">
+<script>
+var i1 = document.getElementById('i1');
+i1.focus();
+i1.blur();
+i1.focus();
+</script>
+</body>
+</html>
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+</head>
+<body>
+<p id="description">Focus field with a placeholder, then type.</p>
+<div>
+<input id=i1 placeholder="Placeholder">
+<script>
+var i1 = document.getElementById('i1');
+i1.focus();
+document.execCommand("InsertText", false, "Text");
+</script>
+</body>
+</html>
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+</head>
+<body>
+<p id="description">Focus field with a placeholder, then type, then delete all text.</p>
+<div>
+<input id=i1 placeholder="Placeholder">
+<script>
+var i1 = document.getElementById('i1');
+i1.focus();
+document.execCommand("InsertText", false, "Text");
+document.execCommand("Delete");
+document.execCommand("Delete");
+document.execCommand("Delete");
+document.execCommand("Delete");
+</script>
+</body>
+</html>
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+</head>
+<body>
+<p id="description">Focus field with a placeholder, then type, then delete all text.</p>
+<div>
+<textarea id=i1 placeholder="Placeholder"></textarea>
+<script>
+var i1 = document.getElementById('i1');
+i1.focus();
+document.execCommand("InsertText", false, "Text");
+document.execCommand("Delete");
+document.execCommand("Delete");
+document.execCommand("Delete");
+document.execCommand("Delete");
+</script>
+</body>
+</html>
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+</head>
+<body>
+<p id="description">Focus field with a placeholder, then type, then clear the value.</p>
+<div>
+<textarea id=i1 placeholder="Placeholder">Text</textarea>
+<script>
+var i1 = document.getElementById('i1');
+i1.focus();
+document.execCommand("InsertText", false, "Text");
+i1.value = "";
+</script>
+</body>
+</html>
--- /dev/null
+0c6c53f074379c9f80c85fea9e717b3c
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 343x18
+ text run at (0,0) width 343: "Focus the field, focus away, then focus the field again."
+ RenderBlock {DIV} at (0,34) size 784x23
+ RenderTextControl {INPUT} at (2,2) size 125x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (0,0) size 0x0
+layer at (13,47) size 119x13
+ RenderBlock {DIV} at (3,3) size 119x13
+caret: position 0 of child 0 {DIV} of child 1 {INPUT} of child 3 {DIV} of body
--- /dev/null
+fd268728e925c0da6638a09255b42a38
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 260x18
+ text run at (0,0) width 260: "Focus field with a placeholder, then type."
+ RenderBlock {DIV} at (0,34) size 784x23
+ RenderTextControl {INPUT} at (2,2) size 125x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (0,0) size 0x0
+layer at (13,47) size 119x13
+ RenderBlock {DIV} at (3,3) size 119x13
+ RenderText {#text} at (1,0) size 24x13
+ text run at (1,0) width 24: "Text"
+caret: position 4 of child 0 {#text} of child 0 {DIV} of child 1 {INPUT} of child 3 {DIV} of body
--- /dev/null
+bfb6305ee070296022d3653ee233a5e5
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 382x18
+ text run at (0,0) width 382: "Focus field with a placeholder, then type, then delete all text."
+ RenderBlock {DIV} at (0,34) size 784x23
+ RenderTextControl {INPUT} at (2,2) size 125x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (0,0) size 0x0
+layer at (13,47) size 119x13
+ RenderBlock {DIV} at (3,3) size 119x13
+ RenderBR {BR} at (1,0) size 0x13
+caret: position 0 of child 0 {BR} of child 0 {DIV} of child 1 {INPUT} of child 3 {DIV} of body
--- /dev/null
+54314a58c654adbca9ec66d0cf5bef0d
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 382x18
+ text run at (0,0) width 382: "Focus field with a placeholder, then type, then delete all text."
+ RenderBlock {DIV} at (0,34) size 784x36
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (0,0) size 0x0
+layer at (10,44) size 161x32 clip at (11,45) size 159x30
+ RenderTextControl {TEXTAREA} at (2,2) size 161x32 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
+ RenderBlock {DIV} at (3,3) size 155x13
+ RenderBR {BR} at (0,0) size 0x13
+caret: position 0 of child 0 {BR} of child 0 {DIV} of child 1 {TEXTAREA} of child 3 {DIV} of body
--- /dev/null
+03c0148ad9cb735b4eaba97c7c16f323
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 390x18
+ text run at (0,0) width 390: "Focus field with a placeholder, then type, then clear the value."
+ RenderBlock {DIV} at (0,34) size 784x36
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (0,0) size 0x0
+layer at (10,44) size 161x32 clip at (11,45) size 159x30
+ RenderTextControl {TEXTAREA} at (2,2) size 161x32 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
+ RenderBlock {DIV} at (3,3) size 155x13
+caret: position 0 of child 0 {DIV} of child 1 {TEXTAREA} of child 3 {DIV} of body
+++ /dev/null
-1ed686cfe61d40b2432e4c49c70741d3
\ No newline at end of file
+++ /dev/null
-layer at (0,0) size 800x600
- RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
- RenderBlock {HTML} at (0,0) size 800x600
- RenderBody {BODY} at (8,8) size 784x584
- RenderBlock {P} at (0,0) size 784x18
- RenderText {#text} at (0,0) size 768x18
- text run at (0,0) width 768: "Bug 45940: A bug that a placeholder text is not cleared by the second focus. The first input field should not have any text."
- RenderBlock {DIV} at (0,34) size 784x23
- RenderTextControl {INPUT} at (2,2) size 125x19 [color=#FF0000] [bgcolor=#FFFFFF] [border: (2px inset #FF0000)]
- RenderText {#text} at (129,2) size 4x18
- text run at (129,2) width 4: " "
- RenderTextControl {INPUT} at (135,2) size 125x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
- RenderText {#text} at (0,0) size 0x0
- RenderText {#text} at (0,0) size 0x0
-layer at (13,47) size 119x13
- RenderBlock {DIV} at (3,3) size 119x13
-layer at (146,47) size 119x13
- RenderBlock {DIV} at (3,3) size 119x13
-caret: position 0 of child 0 {DIV} of child 1 {INPUT} of child 3 {DIV} of body
--- /dev/null
+c717f220212a6b70de4fdd2440806e82
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 343x18
+ text run at (0,0) width 343: "Focus the field, focus away, then focus the field again."
+ RenderBlock {DIV} at (0,34) size 784x23
+ RenderTextControl {INPUT} at (2,2) size 125x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (0,0) size 0x0
+layer at (13,47) size 119x13
+ RenderBlock {DIV} at (3,3) size 119x13
+caret: position 0 of child 0 {DIV} of child 1 {INPUT} of child 3 {DIV} of body
--- /dev/null
+a670922b55df7ab868167e0d1a040419
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 260x18
+ text run at (0,0) width 260: "Focus field with a placeholder, then type."
+ RenderBlock {DIV} at (0,34) size 784x23
+ RenderTextControl {INPUT} at (2,2) size 125x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (0,0) size 0x0
+layer at (13,47) size 119x13
+ RenderBlock {DIV} at (3,3) size 119x13
+ RenderText {#text} at (1,0) size 24x13
+ text run at (1,0) width 24: "Text"
+caret: position 4 of child 0 {#text} of child 0 {DIV} of child 1 {INPUT} of child 3 {DIV} of body
--- /dev/null
+c90c2e1a392e6f723a1a92b315d16945
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 382x18
+ text run at (0,0) width 382: "Focus field with a placeholder, then type, then delete all text."
+ RenderBlock {DIV} at (0,34) size 784x23
+ RenderTextControl {INPUT} at (2,2) size 125x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (0,0) size 0x0
+layer at (13,47) size 119x13
+ RenderBlock {DIV} at (3,3) size 119x13
+ RenderBR {BR} at (1,0) size 0x13
+caret: position 0 of child 0 {BR} of child 0 {DIV} of child 1 {INPUT} of child 3 {DIV} of body
--- /dev/null
+3d936e01970c3e5b7bd1a20571f9cfc6
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 382x18
+ text run at (0,0) width 382: "Focus field with a placeholder, then type, then delete all text."
+ RenderBlock {DIV} at (0,34) size 784x36
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (0,0) size 0x0
+layer at (10,44) size 156x32 clip at (11,45) size 154x30
+ RenderTextControl {TEXTAREA} at (2,2) size 156x32 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
+ RenderBlock {DIV} at (3,3) size 150x13
+ RenderBR {BR} at (0,0) size 0x13
+caret: position 0 of child 0 {BR} of child 0 {DIV} of child 1 {TEXTAREA} of child 3 {DIV} of body
--- /dev/null
+33cf97d7c3d584522eed8c082b5aee70
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 390x18
+ text run at (0,0) width 390: "Focus field with a placeholder, then type, then clear the value."
+ RenderBlock {DIV} at (0,34) size 784x36
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (0,0) size 0x0
+layer at (10,44) size 156x32 clip at (11,45) size 154x30
+ RenderTextControl {TEXTAREA} at (2,2) size 156x32 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
+ RenderBlock {DIV} at (3,3) size 150x13
+caret: position 0 of child 0 {DIV} of child 1 {TEXTAREA} of child 3 {DIV} of body
+2011-02-04 Adele Peterson <adele@apple.com>
+
+ Reviewed by Dan Bernstein.
+
+ Fix for https://bugs.webkit.org/show_bug.cgi?id=53740
+ <rdar://problem/8503629> Allow platforms to specify if the placeholder should be visible when text controls are focused
+
+ Tests:
+ fast/forms/textarea-placeholder-visibility-1.html
+ fast/forms/textarea-placeholder-visibility-2.html
+ fast/forms/input-placeholder-visibility-1.html
+ fast/forms/input-placeholder-visibility-2.html
+ fast/forms/input-placeholder-visibility-3.html
+
+ * html/HTMLFormControlElement.cpp: (WebCore::HTMLTextFormControlElement::placeholderShouldBeVisible):
+ Add a check for shouldShowPlaceholderWhenFocused.
+ * html/HTMLTextAreaElement.cpp: (WebCore::HTMLTextAreaElement::updateValue):
+ Whenever the value is updated, we should also update placeholder visibility.
+ * rendering/RenderTheme.h: (WebCore::RenderTheme::shouldShowPlaceholderWhenFocused):
+ Make the default the same as the existing behavior.
+ * rendering/RenderThemeMac.h:
+ * rendering/RenderThemeMac.mm: (WebCore::RenderThemeMac::shouldShowPlaceholderWhenFocused):
+ Show placeholder when appropriate.
+
2011-02-04 Pavel Podivilov <podivilov@chromium.org>
Reviewed by Pavel Feldman.
{
return supportsPlaceholder()
&& isEmptyValue()
- && document()->focusedNode() != this
- && !isPlaceholderEmpty();
+ && !isPlaceholderEmpty()
+ && (document()->focusedNode() != this || (renderer() && renderer()->theme()->shouldShowPlaceholderWhenFocused()));
}
void HTMLTextFormControlElement::updatePlaceholderVisibility(bool placeholderValueChanged)
const_cast<HTMLTextAreaElement*>(this)->setFormControlValueMatchesRenderer(true);
notifyFormStateChanged(this);
m_isDirty = true;
+ const_cast<HTMLTextAreaElement*>(this)->updatePlaceholderVisibility(false);
}
String HTMLTextAreaElement::value() const
virtual IntSize meterSizeForBounds(const RenderMeter*, const IntRect&) const;
virtual bool supportsMeter(ControlPart, bool isHorizontal) const;
#endif
+
+ virtual bool shouldShowPlaceholderWhenFocused() const { return false; }
protected:
// The platform selection color.
virtual void adjustMediaSliderThumbSize(RenderObject*) const;
virtual IntPoint volumeSliderOffsetFromMuteButton(Node*, const IntSize&) const;
#endif
+
+ virtual bool shouldShowPlaceholderWhenFocused() const;
private:
return IntPoint(xOffset * zoomLevel, y);
}
+bool RenderThemeMac::shouldShowPlaceholderWhenFocused() const
+{
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+ return true;
+#else
+ return false;
+#endif
+}
+
#endif // ENABLE(VIDEO)
NSPopUpButtonCell* RenderThemeMac::popupButton() const