Fix for https://bugs.webkit.org/show_bug.cgi?id=53740
authoradele@apple.com <adele@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Feb 2011 18:18:30 +0000 (18:18 +0000)
committeradele@apple.com <adele@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Feb 2011 18:18:30 +0000 (18:18 +0000)
<rdar://problem/8503629> Allow platforms to specify if the placeholder should be visible when text controls are focused

Reviewed by Dan Bernstein.

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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@77639 268f45cc-cd09-0410-ab3c-d52691b4dbfc

45 files changed:
LayoutTests/fast/forms/input-placeholder-focus-twice.html [deleted file]
LayoutTests/fast/forms/input-placeholder-visibility-1.html [new file with mode: 0644]
LayoutTests/fast/forms/input-placeholder-visibility-2.html [new file with mode: 0644]
LayoutTests/fast/forms/input-placeholder-visibility-3.html [new file with mode: 0644]
LayoutTests/fast/forms/textarea-placeholder-visibility-1.html [new file with mode: 0644]
LayoutTests/fast/forms/textarea-placeholder-visibility-2.html [new file with mode: 0644]
LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-1-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-1-expected.png [new file with mode: 0644]
LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-1-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-2-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-2-expected.png [new file with mode: 0644]
LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-2-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-3-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-3-expected.png [new file with mode: 0644]
LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-3-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-snowleopard/fast/forms/textarea-placeholder-visibility-1-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac-snowleopard/fast/forms/textarea-placeholder-visibility-1-expected.png [new file with mode: 0644]
LayoutTests/platform/mac-snowleopard/fast/forms/textarea-placeholder-visibility-1-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-snowleopard/fast/forms/textarea-placeholder-visibility-2-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac-snowleopard/fast/forms/textarea-placeholder-visibility-2-expected.png [new file with mode: 0644]
LayoutTests/platform/mac-snowleopard/fast/forms/textarea-placeholder-visibility-2-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/forms/input-placeholder-focus-twice-expected.checksum [deleted file]
LayoutTests/platform/mac/fast/forms/input-placeholder-focus-twice-expected.png [deleted file]
LayoutTests/platform/mac/fast/forms/input-placeholder-focus-twice-expected.txt [deleted file]
LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-1-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-1-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-1-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-2-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-2-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-2-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-3-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-3-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-3-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/forms/textarea-placeholder-visibility-1-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/forms/textarea-placeholder-visibility-1-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/forms/textarea-placeholder-visibility-1-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/forms/textarea-placeholder-visibility-2-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/forms/textarea-placeholder-visibility-2-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/forms/textarea-placeholder-visibility-2-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLFormControlElement.cpp
Source/WebCore/html/HTMLTextAreaElement.cpp
Source/WebCore/rendering/RenderTheme.h
Source/WebCore/rendering/RenderThemeMac.h
Source/WebCore/rendering/RenderThemeMac.mm

diff --git a/LayoutTests/fast/forms/input-placeholder-focus-twice.html b/LayoutTests/fast/forms/input-placeholder-focus-twice.html
deleted file mode 100644 (file)
index 41a00e8..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<!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>
diff --git a/LayoutTests/fast/forms/input-placeholder-visibility-1.html b/LayoutTests/fast/forms/input-placeholder-visibility-1.html
new file mode 100644 (file)
index 0000000..59ef586
--- /dev/null
@@ -0,0 +1,16 @@
+<!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>
diff --git a/LayoutTests/fast/forms/input-placeholder-visibility-2.html b/LayoutTests/fast/forms/input-placeholder-visibility-2.html
new file mode 100644 (file)
index 0000000..feb3d4b
--- /dev/null
@@ -0,0 +1,15 @@
+<!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>
diff --git a/LayoutTests/fast/forms/input-placeholder-visibility-3.html b/LayoutTests/fast/forms/input-placeholder-visibility-3.html
new file mode 100644 (file)
index 0000000..dcc92ee
--- /dev/null
@@ -0,0 +1,19 @@
+<!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>
diff --git a/LayoutTests/fast/forms/textarea-placeholder-visibility-1.html b/LayoutTests/fast/forms/textarea-placeholder-visibility-1.html
new file mode 100644 (file)
index 0000000..28f0f8f
--- /dev/null
@@ -0,0 +1,19 @@
+<!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>
diff --git a/LayoutTests/fast/forms/textarea-placeholder-visibility-2.html b/LayoutTests/fast/forms/textarea-placeholder-visibility-2.html
new file mode 100644 (file)
index 0000000..816ef2d
--- /dev/null
@@ -0,0 +1,16 @@
+<!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>
diff --git a/LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-1-expected.checksum b/LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-1-expected.checksum
new file mode 100644 (file)
index 0000000..1df1f0b
--- /dev/null
@@ -0,0 +1 @@
+0c6c53f074379c9f80c85fea9e717b3c
\ No newline at end of file
diff --git a/LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-1-expected.png b/LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-1-expected.png
new file mode 100644 (file)
index 0000000..5d6ae4e
Binary files /dev/null and b/LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-1-expected.png differ
diff --git a/LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-1-expected.txt b/LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-1-expected.txt
new file mode 100644 (file)
index 0000000..ad281f6
--- /dev/null
@@ -0,0 +1,15 @@
+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
diff --git a/LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-2-expected.checksum b/LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-2-expected.checksum
new file mode 100644 (file)
index 0000000..75d8ca5
--- /dev/null
@@ -0,0 +1 @@
+fd268728e925c0da6638a09255b42a38
\ No newline at end of file
diff --git a/LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-2-expected.png b/LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-2-expected.png
new file mode 100644 (file)
index 0000000..e9b0dc6
Binary files /dev/null and b/LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-2-expected.png differ
diff --git a/LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-2-expected.txt b/LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-2-expected.txt
new file mode 100644 (file)
index 0000000..18d8984
--- /dev/null
@@ -0,0 +1,17 @@
+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
diff --git a/LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-3-expected.checksum b/LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-3-expected.checksum
new file mode 100644 (file)
index 0000000..b2cc8b8
--- /dev/null
@@ -0,0 +1 @@
+bfb6305ee070296022d3653ee233a5e5
\ No newline at end of file
diff --git a/LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-3-expected.png b/LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-3-expected.png
new file mode 100644 (file)
index 0000000..c13ec86
Binary files /dev/null and b/LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-3-expected.png differ
diff --git a/LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-3-expected.txt b/LayoutTests/platform/mac-snowleopard/fast/forms/input-placeholder-visibility-3-expected.txt
new file mode 100644 (file)
index 0000000..3269e36
--- /dev/null
@@ -0,0 +1,16 @@
+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
diff --git a/LayoutTests/platform/mac-snowleopard/fast/forms/textarea-placeholder-visibility-1-expected.checksum b/LayoutTests/platform/mac-snowleopard/fast/forms/textarea-placeholder-visibility-1-expected.checksum
new file mode 100644 (file)
index 0000000..446932b
--- /dev/null
@@ -0,0 +1 @@
+54314a58c654adbca9ec66d0cf5bef0d
\ No newline at end of file
diff --git a/LayoutTests/platform/mac-snowleopard/fast/forms/textarea-placeholder-visibility-1-expected.png b/LayoutTests/platform/mac-snowleopard/fast/forms/textarea-placeholder-visibility-1-expected.png
new file mode 100644 (file)
index 0000000..d8a7c47
Binary files /dev/null and b/LayoutTests/platform/mac-snowleopard/fast/forms/textarea-placeholder-visibility-1-expected.png differ
diff --git a/LayoutTests/platform/mac-snowleopard/fast/forms/textarea-placeholder-visibility-1-expected.txt b/LayoutTests/platform/mac-snowleopard/fast/forms/textarea-placeholder-visibility-1-expected.txt
new file mode 100644 (file)
index 0000000..2b1256a
--- /dev/null
@@ -0,0 +1,16 @@
+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
diff --git a/LayoutTests/platform/mac-snowleopard/fast/forms/textarea-placeholder-visibility-2-expected.checksum b/LayoutTests/platform/mac-snowleopard/fast/forms/textarea-placeholder-visibility-2-expected.checksum
new file mode 100644 (file)
index 0000000..7ff9af6
--- /dev/null
@@ -0,0 +1 @@
+03c0148ad9cb735b4eaba97c7c16f323
\ No newline at end of file
diff --git a/LayoutTests/platform/mac-snowleopard/fast/forms/textarea-placeholder-visibility-2-expected.png b/LayoutTests/platform/mac-snowleopard/fast/forms/textarea-placeholder-visibility-2-expected.png
new file mode 100644 (file)
index 0000000..58e1482
Binary files /dev/null and b/LayoutTests/platform/mac-snowleopard/fast/forms/textarea-placeholder-visibility-2-expected.png differ
diff --git a/LayoutTests/platform/mac-snowleopard/fast/forms/textarea-placeholder-visibility-2-expected.txt b/LayoutTests/platform/mac-snowleopard/fast/forms/textarea-placeholder-visibility-2-expected.txt
new file mode 100644 (file)
index 0000000..9ec2f2c
--- /dev/null
@@ -0,0 +1,15 @@
+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
diff --git a/LayoutTests/platform/mac/fast/forms/input-placeholder-focus-twice-expected.checksum b/LayoutTests/platform/mac/fast/forms/input-placeholder-focus-twice-expected.checksum
deleted file mode 100644 (file)
index 54b338a..0000000
+++ /dev/null
@@ -1 +0,0 @@
-1ed686cfe61d40b2432e4c49c70741d3
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/forms/input-placeholder-focus-twice-expected.png b/LayoutTests/platform/mac/fast/forms/input-placeholder-focus-twice-expected.png
deleted file mode 100644 (file)
index 02eda05..0000000
Binary files a/LayoutTests/platform/mac/fast/forms/input-placeholder-focus-twice-expected.png and /dev/null differ
diff --git a/LayoutTests/platform/mac/fast/forms/input-placeholder-focus-twice-expected.txt b/LayoutTests/platform/mac/fast/forms/input-placeholder-focus-twice-expected.txt
deleted file mode 100644 (file)
index 469bd8b..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-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
diff --git a/LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-1-expected.checksum b/LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-1-expected.checksum
new file mode 100644 (file)
index 0000000..3260bed
--- /dev/null
@@ -0,0 +1 @@
+c717f220212a6b70de4fdd2440806e82
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-1-expected.png b/LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-1-expected.png
new file mode 100644 (file)
index 0000000..be675a7
Binary files /dev/null and b/LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-1-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-1-expected.txt b/LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-1-expected.txt
new file mode 100644 (file)
index 0000000..ad281f6
--- /dev/null
@@ -0,0 +1,15 @@
+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
diff --git a/LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-2-expected.checksum b/LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-2-expected.checksum
new file mode 100644 (file)
index 0000000..632d5b2
--- /dev/null
@@ -0,0 +1 @@
+a670922b55df7ab868167e0d1a040419
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-2-expected.png b/LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-2-expected.png
new file mode 100644 (file)
index 0000000..6576fd7
Binary files /dev/null and b/LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-2-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-2-expected.txt b/LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-2-expected.txt
new file mode 100644 (file)
index 0000000..18d8984
--- /dev/null
@@ -0,0 +1,17 @@
+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
diff --git a/LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-3-expected.checksum b/LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-3-expected.checksum
new file mode 100644 (file)
index 0000000..675a3dd
--- /dev/null
@@ -0,0 +1 @@
+c90c2e1a392e6f723a1a92b315d16945
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-3-expected.png b/LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-3-expected.png
new file mode 100644 (file)
index 0000000..45824dd
Binary files /dev/null and b/LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-3-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-3-expected.txt b/LayoutTests/platform/mac/fast/forms/input-placeholder-visibility-3-expected.txt
new file mode 100644 (file)
index 0000000..3269e36
--- /dev/null
@@ -0,0 +1,16 @@
+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
diff --git a/LayoutTests/platform/mac/fast/forms/textarea-placeholder-visibility-1-expected.checksum b/LayoutTests/platform/mac/fast/forms/textarea-placeholder-visibility-1-expected.checksum
new file mode 100644 (file)
index 0000000..6a780ca
--- /dev/null
@@ -0,0 +1 @@
+3d936e01970c3e5b7bd1a20571f9cfc6
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/forms/textarea-placeholder-visibility-1-expected.png b/LayoutTests/platform/mac/fast/forms/textarea-placeholder-visibility-1-expected.png
new file mode 100644 (file)
index 0000000..e276217
Binary files /dev/null and b/LayoutTests/platform/mac/fast/forms/textarea-placeholder-visibility-1-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/forms/textarea-placeholder-visibility-1-expected.txt b/LayoutTests/platform/mac/fast/forms/textarea-placeholder-visibility-1-expected.txt
new file mode 100644 (file)
index 0000000..6e6d220
--- /dev/null
@@ -0,0 +1,16 @@
+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
diff --git a/LayoutTests/platform/mac/fast/forms/textarea-placeholder-visibility-2-expected.checksum b/LayoutTests/platform/mac/fast/forms/textarea-placeholder-visibility-2-expected.checksum
new file mode 100644 (file)
index 0000000..fb08919
--- /dev/null
@@ -0,0 +1 @@
+33cf97d7c3d584522eed8c082b5aee70
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/forms/textarea-placeholder-visibility-2-expected.png b/LayoutTests/platform/mac/fast/forms/textarea-placeholder-visibility-2-expected.png
new file mode 100644 (file)
index 0000000..01e99ab
Binary files /dev/null and b/LayoutTests/platform/mac/fast/forms/textarea-placeholder-visibility-2-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/forms/textarea-placeholder-visibility-2-expected.txt b/LayoutTests/platform/mac/fast/forms/textarea-placeholder-visibility-2-expected.txt
new file mode 100644 (file)
index 0000000..c9e88da
--- /dev/null
@@ -0,0 +1,15 @@
+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
index 088a6cd..dd9463e 100644 (file)
@@ -1,3 +1,27 @@
+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.
index 0daa521..2f3db08 100644 (file)
@@ -582,8 +582,8 @@ bool HTMLTextFormControlElement::placeholderShouldBeVisible() const
 {
     return supportsPlaceholder()
         && isEmptyValue()
-        && document()->focusedNode() != this
-        && !isPlaceholderEmpty();
+        && !isPlaceholderEmpty()
+        && (document()->focusedNode() != this || (renderer() && renderer()->theme()->shouldShowPlaceholderWhenFocused()));
 }
 
 void HTMLTextFormControlElement::updatePlaceholderVisibility(bool placeholderValueChanged)
index ea1f62b..4336131 100644 (file)
@@ -277,6 +277,7 @@ void HTMLTextAreaElement::updateValue() const
     const_cast<HTMLTextAreaElement*>(this)->setFormControlValueMatchesRenderer(true);
     notifyFormStateChanged(this);
     m_isDirty = true;
+    const_cast<HTMLTextAreaElement*>(this)->updatePlaceholderVisibility(false);
 }
 
 String HTMLTextAreaElement::value() const
index d50a9c4..b2d1585 100644 (file)
@@ -194,6 +194,8 @@ public:
     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.
index 95661b8..a2644e2 100644 (file)
@@ -167,6 +167,8 @@ protected:
     virtual void adjustMediaSliderThumbSize(RenderObject*) const;
     virtual IntPoint volumeSliderOffsetFromMuteButton(Node*, const IntSize&) const;
 #endif
+    
+    virtual bool shouldShowPlaceholderWhenFocused() const;
 
 private:
 
index 2a3f9fa..f1384ef 100644 (file)
@@ -1994,6 +1994,15 @@ IntPoint RenderThemeMac::volumeSliderOffsetFromMuteButton(Node* muteButton, cons
     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