[prev in list] [next in list] [prev in thread] [next in thread]
List: webkit-changes
Subject: [webkit-changes] [37123] trunk
From: adele () apple ! com
Date: 2008-09-30 23:21:50
Message-ID: 20080930232151.68D5A449965 () beta ! macosforge ! org
[Download RAW message or body]
[Attachment #2 (text/html)]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[37123] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: \
verdana,arial,helvetica,sans-serif; font-size: 10pt; } #msg dl a { font-weight: \
bold} #msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: \
bold; } #msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: \
6px; } #logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em \
0; } #logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg \
h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; } \
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; \
} #logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: \
-1.5em; padding-left: 1.5em; } #logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em \
1em 0 1em; background: white;} #logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid \
#fa0; border-bottom: 1px solid #fa0; background: #fff; } #logmsg table th { \
text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted \
#fa0; } #logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: \
0.2em 0.5em; } #logmsg table thead th { text-align: center; border-bottom: 1px solid \
#fa0; } #logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: \
6px; } #patch { width: 100%; }
#patch h4 {font-family: \
verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, \
#patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins \
{background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del \
{background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, \
.info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a \
href="http://trac.webkit.org/projects/webkit/changeset/37123">37123</a></dd> \
<dt>Author</dt> <dd>adele@apple.com</dd> <dt>Date</dt> <dd>2008-09-30 16:21:50 -0700 \
(Tue, 30 Sep 2008)</dd> </dl>
<h3>Log Message</h3>
<pre>WebCore:
2008-09-30 Adele Peterson <adele@apple.com>
Reviewed by Darin Adler.
Fix for https://bugs.webkit.org/show_bug.cgi?id=21227
<rdar://problem/6222134> add a way to set color for input placeholder \
text
Test: fast/forms/placeholder-pseudo-style.html
This change adds "-webkit-input-placeholder-mode" as a pseudo class \
that can be used to style input elements when they are displaying the placeholder \
text.
* css/CSSSelector.cpp: (WebCore::CSSSelector::extractPseudoType): Add case \
for inputPlaceholderMode.
* css/CSSSelector.h: (WebCore::CSSSelector::): Add \
PseudoInputPlaceholderMode.
* css/CSSStyleSelector.cpp: \
(WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector):
Add check for PseudoInputPlaceholderMode that asks the node if \
placeholderShouldBeVisible is true.
* css/html4.css: Add rule to make placeholder text default to darkGray.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::init): Initialize m_placeholderShouldBeVisible.
(WebCore::HTMLInputElement::dispatchFocusEvent): Call \
updatePlaceholderVisibility. (WebCore::HTMLInputElement::dispatchBlurEvent): ditto.
(WebCore::HTMLInputElement::parseMappedAttribute): ditto.
(WebCore::HTMLInputElement::setValue): ditto.
(WebCore::HTMLInputElement::setValueFromRenderer): ditto.
(WebCore::HTMLInputElement::updatePlaceholderVisibility): Sets \
m_placeholderShouldBeVisible based on the current value and the focus \
state.
This calculation used to be done in the renderer, but since the node knows \
everything about the state, it can make that decision, and the
renderer will just ask the node if it should draw the placeholder.
* html/HTMLInputElement.h: \
(WebCore::HTMLInputElement::placeholderShouldBeVisible):
* rendering/RenderTextControl.cpp:
(WebCore::disabledTextColor): Moved to the top of the file. If there's not \
very much contrast between the disabled color and the background \
color,
just leave the text color alone. We don't want to change a good contrast \
color scheme so that it has really bad contrast.
If the the contrast was already poor, then it doesn't do any good to change \
it to a different poor contrast color scheme. \
(WebCore::RenderTextControl::createInnerTextStyle): If the node says the placeholder \
should be visible, prepare by overriding the text security to be \
"none".
This can only happen as a result of either a setStyle call (which will be \
followed by a call to updateFromElement) or from \
createSubtreeIfNeeded, which
is called directly from updateFromElement. updateFromElement will \
immediately update the text displayed.
(WebCore::RenderTextControl::updateFromElement): If the placeholder \
visibility has changed, update the text that is displayed.
(WebCore::RenderTextControl::forwardEvent): Remove calls to update the \
placeholder state. This is now done in HTMLInputElement.
* rendering/RenderTextControl.h:
LayoutTests:
2008-09-30 Adele Peterson <adele@apple.com>
Reviewed by Darin Adler.
Tests for https://bugs.webkit.org/show_bug.cgi?id=21227
<rdar://problem/6222134> add a way to set color for input placeholder \
text
* fast/forms/password-placeholder-text-security.html: Added.
* fast/forms/placeholder-pseudo-style.html: Added.
* platform/mac/fast/forms/password-placeholder-text-security-expected.checksum: \
Added.
* platform/mac/fast/forms/password-placeholder-text-security-expected.png: \
Added.
* platform/mac/fast/forms/password-placeholder-text-security-expected.txt: \
Added.
* platform/mac/fast/forms/placeholder-pseudo-style-expected.checksum: Added.
* platform/mac/fast/forms/placeholder-pseudo-style-expected.png: Added.
* platform/mac/fast/forms/placeholder-pseudo-style-expected.txt: Added.
Updated results. The placeholder color is now reflected on the \
RenderTextControl, not just on an inner element.
* platform/mac/fast/forms/input-disabled-color-expected.checksum:
* platform/mac/fast/forms/input-disabled-color-expected.png:
* platform/mac/fast/forms/input-disabled-color-expected.txt:
* platform/mac/fast/forms/password-placeholder-expected.checksum:
* platform/mac/fast/forms/password-placeholder-expected.png:
* platform/mac/fast/forms/password-placeholder-expected.txt:
* platform/mac/fast/forms/placeholder-set-attribute-expected.checksum:
* platform/mac/fast/forms/placeholder-set-attribute-expected.png:
* platform/mac/fast/forms/placeholder-set-attribute-expected.txt:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastformsinputdisabledcolorexpectedchecksum"> \
trunk/LayoutTests/platform/mac/fast/forms/input-disabled-color-expected.checksum</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastformsinputdisabledcolorexpectedpng">trunk/LayoutTests/platform/mac/fast/forms/input-disabled-color-expected.png</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastformsinputdisabledcolorexpectedtxt">trunk/LayoutTests/platform/mac/fast/forms/input-disabled-color-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastformspasswordplaceholderexpectedchecksum \
">trunk/LayoutTests/platform/mac/fast/forms/password-placeholder-expected.checksum</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastformspasswordplaceholderexpectedpng">tru \
nk/LayoutTests/platform/mac/fast/forms/password-placeholder-expected.png</a></li> \
<li><a href="#trunkLayoutTestsplatformmacfastformspasswordplaceholderexpectedtxt">trunk/LayoutTests/platform/mac/fast/forms/password-placeholder-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastformsplaceholdersetattributeexpectedchec \
ksum">trunk/LayoutTests/platform/mac/fast/forms/placeholder-set-attribute-expected.checksum</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastformsplaceholdersetattributeexpectedpng" \
>trunk/LayoutTests/platform/mac/fast/forms/placeholder-set-attribute-expected.png</a></li>
>
<li><a href="#trunkLayoutTestsplatformmacfastformsplaceholdersetattributeexpectedtxt"> \
trunk/LayoutTests/platform/mac/fast/forms/placeholder-set-attribute-expected.txt</a></li>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCorecssCSSSelectorcpp">trunk/WebCore/css/CSSSelector.cpp</a></li>
<li><a href="#trunkWebCorecssCSSSelectorh">trunk/WebCore/css/CSSSelector.h</a></li>
<li><a href="#trunkWebCorecssCSSStyleSelectorcpp">trunk/WebCore/css/CSSStyleSelector.cpp</a></li>
<li><a href="#trunkWebCorecsshtml4css">trunk/WebCore/css/html4.css</a></li>
<li><a href="#trunkWebCorehtmlHTMLInputElementcpp">trunk/WebCore/html/HTMLInputElement.cpp</a></li>
<li><a href="#trunkWebCorehtmlHTMLInputElementh">trunk/WebCore/html/HTMLInputElement.h</a></li>
<li><a href="#trunkWebCorerenderingRenderTextControlcpp">trunk/WebCore/rendering/RenderTextControl.cpp</a></li>
<li><a href="#trunkWebCorerenderingRenderTextControlh">trunk/WebCore/rendering/RenderTextControl.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastformspasswordplaceholdertextsecurityhtml">trunk/LayoutTests/fast/forms/password-placeholder-text-security.html</a></li>
<li><a href="#trunkLayoutTestsfastformsplaceholderpseudostylehtml">trunk/LayoutTests/fast/forms/placeholder-pseudo-style.html</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastformspasswordplaceholdertextsecurityexpe \
ctedchecksum">trunk/LayoutTests/platform/mac/fast/forms/password-placeholder-text-security-expected.checksum</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastformspasswordplaceholdertextsecurityexpe \
ctedpng">trunk/LayoutTests/platform/mac/fast/forms/password-placeholder-text-security-expected.png</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastformspasswordplaceholdertextsecurityexpe \
ctedtxt">trunk/LayoutTests/platform/mac/fast/forms/password-placeholder-text-security-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastformsplaceholderpseudostyleexpectedcheck \
sum">trunk/LayoutTests/platform/mac/fast/forms/placeholder-pseudo-style-expected.checksum</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastformsplaceholderpseudostyleexpectedpng"> \
trunk/LayoutTests/platform/mac/fast/forms/placeholder-pseudo-style-expected.png</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastformsplaceholderpseudostyleexpectedtxt"> \
trunk/LayoutTests/platform/mac/fast/forms/placeholder-pseudo-style-expected.txt</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (37122 => 37123)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog 2008-09-30 23:19:53 UTC (rev \
37122)
+++ trunk/LayoutTests/ChangeLog 2008-09-30 23:21:50 UTC (rev 37123)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2008-09-30 Adele Peterson <adele@apple.com>
+
+ Reviewed by Darin Adler.
+
+ Tests for https://bugs.webkit.org/show_bug.cgi?id=21227
+ <rdar://problem/6222134> add a way to set color for input placeholder \
text +
+ * fast/forms/password-placeholder-text-security.html: Added.
+ * fast/forms/placeholder-pseudo-style.html: Added.
+ * platform/mac/fast/forms/password-placeholder-text-security-expected.checksum: \
Added. + * platform/mac/fast/forms/password-placeholder-text-security-expected.png: \
Added. + * platform/mac/fast/forms/password-placeholder-text-security-expected.txt: \
Added. + * platform/mac/fast/forms/placeholder-pseudo-style-expected.checksum: \
Added. + * platform/mac/fast/forms/placeholder-pseudo-style-expected.png: \
Added. + * platform/mac/fast/forms/placeholder-pseudo-style-expected.txt: \
Added. +
+ Updated results. The placeholder color is now reflected on the \
RenderTextControl, not just on an inner element. +
+ * platform/mac/fast/forms/input-disabled-color-expected.checksum:
+ * platform/mac/fast/forms/input-disabled-color-expected.png:
+ * platform/mac/fast/forms/input-disabled-color-expected.txt:
+ * platform/mac/fast/forms/password-placeholder-expected.checksum:
+ * platform/mac/fast/forms/password-placeholder-expected.png:
+ * platform/mac/fast/forms/password-placeholder-expected.txt:
+ * platform/mac/fast/forms/placeholder-set-attribute-expected.checksum:
+ * platform/mac/fast/forms/placeholder-set-attribute-expected.png:
+ * platform/mac/fast/forms/placeholder-set-attribute-expected.txt:
+
</ins><span class="cx"> 2008-09-30 Beth Dakin <bdakin@apple.com>
</span><span class="cx">
</span><span class="cx"> Reviewed by Darin Adler.
</span></span></pre></div>
<a id="trunkLayoutTestsfastformspasswordplaceholdertextsecurityhtml"></a>
<div class="addfile"><h4>Added: \
trunk/LayoutTests/fast/forms/password-placeholder-text-security.html (0 => \
37123)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/LayoutTests/fast/forms/password-placeholder-text-security.html \
(rev 0)
+++ trunk/LayoutTests/fast/forms/password-placeholder-text-security.html 2008-09-30 \
23:21:50 UTC (rev 37123) </span><span class="lines">@@ -0,0 +1,36 @@
</span><ins>+<html>
+ <head>
+ <script>
+ function test()
+ {
+ if (window.layoutTestController)
+ layoutTestController.waitUntilDone();
+
+ // 1) leave field 1 alone. It should show the placeholder text.
+ // 2) focus field 2 and type. It should show bullets for the \
password. + var password = \
document.getElementById("pass2"); + password.focus();
+ document.execCommand("InsertText", false, \
"test"); + // 3) focus field 3 and type. Clear the value \
and blur the field. It should show the placeholder text. + \
password = document.getElementById("pass3"); + \
password.focus(); + document.execCommand("InsertText", \
false, "test"); + password.value = "";
+ password.blur();
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
+ function log(msg)
+ {
+ document.getElementById('console').appendChild(document.createTextNode(msg \
+ "\n")); + }
+ </script>
+ </head>
+ <body onload="test()">
+ This tests that the text security mode switches correctly when the \
placeholder appears and disappears.<br> + Leave field 1 alone. It should \
show the placeholder text: <input type="password" id="pass1" \
placeholder="placeholder"><br> + Focus field 2 and type. \
It should show bullets for the password.: <input type="password" \
id="pass2" placeholder="placeholder"><br> + Focus \
field 3 and type. Clear the value and blur the field. It should show the \
placeholder text: <input type="password" id="pass3" \
placeholder="placeholder"><br> + </body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsplaceholderpseudostylehtml"></a>
<div class="addfile"><h4>Added: \
trunk/LayoutTests/fast/forms/placeholder-pseudo-style.html (0 => 37123)</h4> <pre \
class="diff"><span> <span class="info">--- \
trunk/LayoutTests/fast/forms/placeholder-pseudo-style.html \
(rev 0)
+++ trunk/LayoutTests/fast/forms/placeholder-pseudo-style.html 2008-09-30 23:21:50 \
UTC (rev 37123) </span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+<style>
+input.red:-webkit-input-placeholder-mode {
+ color: rgb(100, 0, 0);
+}
+</style>
+This tests that you can set the placeholder text color.<br>
+<input class="red" placeholder="text">
+<input class="red" type="search" \
placeholder="search"> +<input class="red" \
type="password" placeholder="password"> +<input \
class="red" disabled placeholder="disabled text"> +<input \
placeholder="default"> +<input placeholder="default \
disabled"> </ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacfastformsinputdisabledcolorexpectedchecksum"></a>
<div class="modfile"><h4>Modified: \
trunk/LayoutTests/platform/mac/fast/forms/input-disabled-color-expected.checksum \
(37122 => 37123)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/LayoutTests/platform/mac/fast/forms/input-disabled-color-expected.checksum 2008-09-30 \
23:19:53 UTC (rev 37122)
+++ trunk/LayoutTests/platform/mac/fast/forms/input-disabled-color-expected.checksum 2008-09-30 \
23:21:50 UTC (rev 37123) </span><span class="lines">@@ -1 +1 @@
</span><del>-a6f4c1280e857f210a29112c8b670771
</del><span class="cx">\ No newline at end of file
</span><ins>+c54c765ce3626d34ea5606ed65cd03cd
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacfastformsinputdisabledcolorexpectedpng"></a>
<div class="binary"><h4>Modified: \
trunk/LayoutTests/platform/mac/fast/forms/input-disabled-color-expected.png</h4> <pre \
class="diff"><span> <span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacfastformsinputdisabledcolorexpectedtxt"></a>
<div class="modfile"><h4>Modified: \
trunk/LayoutTests/platform/mac/fast/forms/input-disabled-color-expected.txt (37122 => \
37123)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/LayoutTests/platform/mac/fast/forms/input-disabled-color-expected.txt 2008-09-30 \
23:19:53 UTC (rev 37122)
+++ trunk/LayoutTests/platform/mac/fast/forms/input-disabled-color-expected.txt 2008-09-30 \
23:21:50 UTC (rev 37123) </span><span class="lines">@@ -118,7 +118,7 @@
</span><span class="cx"> RenderText {#text} at (1,0) size 156x13
</span><span class="cx"> text run at (1,0) width 156: "This text field is \
not disabled" </span><span class="cx"> layer at (13,192) size 142x13 scrollWidth \
356 </span><del>- RenderBlock {DIV} at (3,3) size 142x13 [color=#ABABAB]
</del><ins>+ RenderBlock {DIV} at (3,3) size 142x13
</ins><span class="cx"> RenderText {#text} at (1,0) size 355x13
</span><span class="cx"> text run at (1,0) width 355: "The text in this \
disabled field should displayed as dimmed or grey" </span><span class="cx"> \
layer at (169,192) size 142x13 scrollWidth 158 </span></span></pre></div>
<a id="trunkLayoutTestsplatformmacfastformspasswordplaceholderexpectedchecksum"></a>
<div class="modfile"><h4>Modified: \
trunk/LayoutTests/platform/mac/fast/forms/password-placeholder-expected.checksum \
(37122 => 37123)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/LayoutTests/platform/mac/fast/forms/password-placeholder-expected.checksum 2008-09-30 \
23:19:53 UTC (rev 37122)
+++ trunk/LayoutTests/platform/mac/fast/forms/password-placeholder-expected.checksum 2008-09-30 \
23:21:50 UTC (rev 37123) </span><span class="lines">@@ -1 +1 @@
</span><del>-96559e5e202b3b9774ff1689ceaf726f
</del><span class="cx">\ No newline at end of file
</span><ins>+5cf4696ebda55d530e503126cadf3b97
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacfastformspasswordplaceholderexpectedpng"></a>
<div class="binary"><h4>Modified: \
trunk/LayoutTests/platform/mac/fast/forms/password-placeholder-expected.png</h4> <pre \
class="diff"><span> <span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacfastformspasswordplaceholderexpectedtxt"></a>
<div class="modfile"><h4>Modified: \
trunk/LayoutTests/platform/mac/fast/forms/password-placeholder-expected.txt (37122 => \
37123)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/LayoutTests/platform/mac/fast/forms/password-placeholder-expected.txt 2008-09-30 \
23:19:53 UTC (rev 37122)
+++ trunk/LayoutTests/platform/mac/fast/forms/password-placeholder-expected.txt 2008-09-30 \
23:21:50 UTC (rev 37123) </span><span class="lines">@@ -3,9 +3,9 @@
</span><span class="cx"> layer at (0,0) size 800x600
</span><span class="cx"> RenderBlock {HTML} at (0,0) size 800x600
</span><span class="cx"> RenderBody {BODY} at (8,8) size 784x584
</span><del>- RenderTextControl {INPUT} at (2,2) size 148x19 [bgcolor=#FFFFFF] \
[border: (2px inset #000000)] </del><ins>+ RenderTextControl {INPUT} at (2,2) \
size 148x19 [color=#A9A9A9] [bgcolor=#FFFFFF] [border: (2px inset #A9A9A9)] \
</ins><span class="cx"> RenderText {#text} at (0,0) size 0x0 </span><span \
class="cx"> layer at (13,13) size 142x13 </span><del>- RenderBlock {DIV} at (3,3) \
size 142x13 [color=#808080] </del><ins>+ RenderBlock {DIV} at (3,3) size 142x13
</ins><span class="cx"> RenderText {#text} at (1,0) size 36x13
</span><span class="cx"> text run at (1,0) width 36: "foobar"
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacfastformspasswordplaceholdertextsecurityexpectedchecksum"></a>
<div class="addfile"><h4>Added: \
trunk/LayoutTests/platform/mac/fast/forms/password-placeholder-text-security-expected.checksum \
(0 => 37123)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/LayoutTests/platform/mac/fast/forms/password-placeholder-text-security-expected.checksum \
(rev 0)
+++ trunk/LayoutTests/platform/mac/fast/forms/password-placeholder-text-security-expected.checksum 2008-09-30 \
23:21:50 UTC (rev 37123) </span><span class="lines">@@ -0,0 +1 @@
</span><ins>+9dc90e9f4705b34ae7f4fdc81fa5fbea
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacfastformspasswordplaceholdertextsecurityexpectedpng"></a>
<div class="binary"><h4>Added: \
trunk/LayoutTests/platform/mac/fast/forms/password-placeholder-text-security-expected.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: \
trunk/LayoutTests/platform/mac/fast/forms/password-placeholder-text-security-expected.png
</span><span class="cx">___________________________________________________________________
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkLayoutTestsplatformmacfastformspasswordplaceholdertextsecurityexpectedtxt"></a>
<div class="addfile"><h4>Added: \
trunk/LayoutTests/platform/mac/fast/forms/password-placeholder-text-security-expected.txt \
(0 => 37123)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/LayoutTests/platform/mac/fast/forms/password-placeholder-text-security-expected.txt \
(rev 0)
+++ trunk/LayoutTests/platform/mac/fast/forms/password-placeholder-text-security-expected.txt 2008-09-30 \
23:21:50 UTC (rev 37123) </span><span class="lines">@@ -0,0 +1,35 @@
</span><ins>+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
+ RenderText {#text} at (0,0) size 637x18
+ text run at (0,0) width 637: "This tests that the text security mode \
switches correctly when the placeholder appears and disappears." + RenderBR \
{BR} at (637,14) size 0x0 + RenderText {#text} at (0,20) size 357x18
+ text run at (0,20) width 357: "Leave field 1 alone. It should show the \
placeholder text: " + RenderTextControl {INPUT} at (359,20) size 148x19 \
[color=#A9A9A9] [bgcolor=#FFFFFF] [border: (2px inset #A9A9A9)] + RenderBR {BR} \
at (509,34) size 0x0 + RenderText {#text} at (0,43) size 407x18
+ text run at (0,43) width 148: "Focus field 2 and type. "
+ text run at (148,43) width 259: "It should show bullets for the \
password.: " + RenderTextControl {INPUT} at (409,43) size 148x19 \
[bgcolor=#FFFFFF] [border: (2px inset #000000)] + RenderBR {BR} at (559,57) size \
0x0 + RenderText {#text} at (0,66) size 590x18
+ text run at (0,66) width 148: "Focus field 3 and type. "
+ text run at (148,66) width 214: "Clear the value and blur the field. \
" + text run at (362,66) width 228: "It should show the placeholder \
text: " + RenderTextControl {INPUT} at (592,66) size 148x19 [color=#A9A9A9] \
[bgcolor=#FFFFFF] [border: (2px inset #A9A9A9)] + RenderBR {BR} at (742,80) size \
0x0 +layer at (370,31) size 142x13
+ RenderBlock {DIV} at (3,3) size 142x13
+ RenderText {#text} at (1,0) size 63x13
+ text run at (1,0) width 63: "placeholder"
+layer at (420,54) size 142x13
+ RenderBlock {DIV} at (3,3) size 142x13
+ RenderText {#text} at (1,0) size 25x13
+ text run at (1,0) width 25: "\x{2022}\x{2022}\x{2022}\x{2022}"
+layer at (603,77) size 142x13
+ RenderBlock {DIV} at (3,3) size 142x13
+ RenderText {#text} at (1,0) size 63x13
+ text run at (1,0) width 63: "placeholder"
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacfastformsplaceholderpseudostyleexpectedchecksum"></a>
<div class="addfile"><h4>Added: \
trunk/LayoutTests/platform/mac/fast/forms/placeholder-pseudo-style-expected.checksum \
(0 => 37123)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/LayoutTests/platform/mac/fast/forms/placeholder-pseudo-style-expected.checksum \
(rev 0)
+++ trunk/LayoutTests/platform/mac/fast/forms/placeholder-pseudo-style-expected.checksum 2008-09-30 \
23:21:50 UTC (rev 37123) </span><span class="lines">@@ -0,0 +1 @@
</span><ins>+324a8f21eae92afe4daf905543428687
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacfastformsplaceholderpseudostyleexpectedpng"></a>
<div class="binary"><h4>Added: \
trunk/LayoutTests/platform/mac/fast/forms/placeholder-pseudo-style-expected.png</h4> \
<pre class="diff"><span> <span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: \
trunk/LayoutTests/platform/mac/fast/forms/placeholder-pseudo-style-expected.png \
</span><span class="cx">___________________________________________________________________
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkLayoutTestsplatformmacfastformsplaceholderpseudostyleexpectedtxt"></a>
<div class="addfile"><h4>Added: \
trunk/LayoutTests/platform/mac/fast/forms/placeholder-pseudo-style-expected.txt (0 => \
37123)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/LayoutTests/platform/mac/fast/forms/placeholder-pseudo-style-expected.txt \
(rev 0)
+++ trunk/LayoutTests/platform/mac/fast/forms/placeholder-pseudo-style-expected.txt 2008-09-30 \
23:21:50 UTC (rev 37123) </span><span class="lines">@@ -0,0 +1,52 @@
</span><ins>+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
+ RenderText {#text} at (0,0) size 328x18
+ text run at (0,0) width 328: "This tests that you can set the \
placeholder text color." + RenderBR {BR} at (328,14) size 0x0
+ RenderTextControl {INPUT} at (2,20) size 148x19 [color=#640000] \
[bgcolor=#FFFFFF] [border: (2px inset #640000)] + RenderText {#text} at (152,20) \
size 4x18 + text run at (152,20) width 4: " "
+ RenderTextControl {INPUT} at (158,20) size 148x19 [color=#640000] \
[bgcolor=#FFFFFF] [border: (2px inset #640000)] + RenderBlock {DIV} at (3,3) \
size 142x13 + RenderBlock {DIV} at (0,0) size 8x11
+ RenderBlock {DIV} at (129,0) size 13x11
+ RenderText {#text} at (308,20) size 4x18
+ text run at (308,20) width 4: " "
+ RenderTextControl {INPUT} at (314,20) size 148x19 [color=#640000] \
[bgcolor=#FFFFFF] [border: (2px inset #640000)] + RenderText {#text} at (464,20) \
size 4x18 + text run at (464,20) width 4: " "
+ RenderTextControl {INPUT} at (470,20) size 148x19 [color=#640000] \
[bgcolor=#FFFFFF] [border: (2px inset #640000)] + RenderText {#text} at (620,20) \
size 4x18 + text run at (620,20) width 4: " "
+ RenderTextControl {INPUT} at (626,20) size 148x19 [color=#A9A9A9] \
[bgcolor=#FFFFFF] [border: (2px inset #A9A9A9)] + RenderText {#text} at (776,20) \
size 4x18 + text run at (776,20) width 4: " "
+ RenderTextControl {INPUT} at (2,43) size 148x19 [color=#A9A9A9] \
[bgcolor=#FFFFFF] [border: (2px inset #A9A9A9)] + RenderText {#text} at (0,0) \
size 0x0 +layer at (13,31) size 142x13
+ RenderBlock {DIV} at (3,3) size 142x13
+ RenderText {#text} at (1,0) size 22x13
+ text run at (1,0) width 22: "text"
+layer at (177,31) size 121x13
+ RenderBlock {DIV} at (8,0) size 121x13
+ RenderText {#text} at (1,0) size 35x13
+ text run at (1,0) width 35: "search"
+layer at (325,31) size 142x13
+ RenderBlock {DIV} at (3,3) size 142x13
+ RenderText {#text} at (1,0) size 51x13
+ text run at (1,0) width 51: "password"
+layer at (481,31) size 142x13
+ RenderBlock {DIV} at (3,3) size 142x13 [color=#B80000]
+ RenderText {#text} at (1,0) size 70x13
+ text run at (1,0) width 70: "disabled text"
+layer at (637,31) size 142x13
+ RenderBlock {DIV} at (3,3) size 142x13
+ RenderText {#text} at (1,0) size 38x13
+ text run at (1,0) width 38: "default"
+layer at (13,54) size 142x13
+ RenderBlock {DIV} at (3,3) size 142x13
+ RenderText {#text} at (1,0) size 86x13
+ text run at (1,0) width 86: "default disabled"
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacfastformsplaceholdersetattributeexpectedchecksum"></a>
<div class="modfile"><h4>Modified: \
trunk/LayoutTests/platform/mac/fast/forms/placeholder-set-attribute-expected.checksum \
(37122 => 37123)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/LayoutTests/platform/mac/fast/forms/placeholder-set-attribute-expected.checksum 2008-09-30 \
23:19:53 UTC (rev 37122)
+++ trunk/LayoutTests/platform/mac/fast/forms/placeholder-set-attribute-expected.checksum 2008-09-30 \
23:21:50 UTC (rev 37123) </span><span class="lines">@@ -1 +1 @@
</span><del>-6d1463e5373bdf10e7df94df12a7da83
</del><span class="cx">\ No newline at end of file
</span><ins>+d6a054a092f3df8e121346759452e52b
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacfastformsplaceholdersetattributeexpectedpng"></a>
<div class="binary"><h4>Modified: \
trunk/LayoutTests/platform/mac/fast/forms/placeholder-set-attribute-expected.png</h4> \
<pre class="diff"><span> <span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacfastformsplaceholdersetattributeexpectedtxt"></a>
<div class="modfile"><h4>Modified: \
trunk/LayoutTests/platform/mac/fast/forms/placeholder-set-attribute-expected.txt \
(37122 => 37123)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/LayoutTests/platform/mac/fast/forms/placeholder-set-attribute-expected.txt 2008-09-30 \
23:19:53 UTC (rev 37122)
+++ trunk/LayoutTests/platform/mac/fast/forms/placeholder-set-attribute-expected.txt 2008-09-30 \
23:21:50 UTC (rev 37123) </span><span class="lines">@@ -7,8 +7,8 @@
</span><span class="cx"> RenderText {#text} at (0,0) size 441x18
</span><span class="cx"> text run at (0,0) width 441: "If you can see \
the word \"Placeholder\" in the text field, then all is well." \
</span><span class="cx"> RenderBlock {P} at (0,34) size 784x23 </span><del>- \
RenderTextControl {INPUT} at (2,2) size 148x19 [bgcolor=#FFFFFF] [border: (2px inset \
#000000)] </del><ins>+ RenderTextControl {INPUT} at (2,2) size 148x19 \
[color=#A9A9A9] [bgcolor=#FFFFFF] [border: (2px inset #A9A9A9)] </ins><span \
class="cx"> layer at (13,47) size 142x13 </span><del>- RenderBlock {DIV} at (3,3) \
size 142x13 [color=#808080] </del><ins>+ RenderBlock {DIV} at (3,3) size 142x13
</ins><span class="cx"> RenderText {#text} at (1,0) size 62x13
</span><span class="cx"> text run at (1,0) width 62: "Placeholder"
</span></span></pre></div>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (37122 => 37123)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog 2008-09-30 23:19:53 UTC (rev 37122)
+++ trunk/WebCore/ChangeLog 2008-09-30 23:21:50 UTC (rev 37123)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2008-09-30 Adele Peterson <adele@apple.com>
+
+ Reviewed by Darin Adler.
+
+ Fix for https://bugs.webkit.org/show_bug.cgi?id=21227
+ <rdar://problem/6222134> add a way to set color for input placeholder \
text +
+ Test: fast/forms/placeholder-pseudo-style.html
+
+ This change adds "-webkit-input-placeholder-mode" as a pseudo \
class that can be used to style + input elements when they are displaying the \
placeholder text. +
+ * css/CSSSelector.cpp: (WebCore::CSSSelector::extractPseudoType): Add case \
for inputPlaceholderMode. + * css/CSSSelector.h: (WebCore::CSSSelector::): Add \
PseudoInputPlaceholderMode. + * css/CSSStyleSelector.cpp: \
(WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector): + Add check \
for PseudoInputPlaceholderMode that asks the node if placeholderShouldBeVisible is \
true. + * css/html4.css: Add rule to make placeholder text default to \
darkGray. +
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::init): Initialize m_placeholderShouldBeVisible.
+ (WebCore::HTMLInputElement::dispatchFocusEvent): Call \
updatePlaceholderVisibility. + (WebCore::HTMLInputElement::dispatchBlurEvent): \
ditto. + (WebCore::HTMLInputElement::parseMappedAttribute): ditto.
+ (WebCore::HTMLInputElement::setValue): ditto.
+ (WebCore::HTMLInputElement::setValueFromRenderer): ditto.
+ (WebCore::HTMLInputElement::updatePlaceholderVisibility): Sets \
m_placeholderShouldBeVisible based on the current value and the focus state. + \
This calculation used to be done in the renderer, but since the node knows everything \
about the state, it can make that decision, and the + renderer will just ask \
the node if it should draw the placeholder. + * html/HTMLInputElement.h: \
(WebCore::HTMLInputElement::placeholderShouldBeVisible): +
+ * rendering/RenderTextControl.cpp:
+ (WebCore::disabledTextColor): Moved to the top of the file. If there's not \
very much contrast between the disabled color and the background color, + just \
leave the text color alone. We don't want to change a good contrast color scheme so \
that it has really bad contrast. + If the the contrast was already poor, then \
it doesn't do any good to change it to a different poor contrast color scheme. + \
(WebCore::RenderTextControl::createInnerTextStyle): If the node says the placeholder \
should be visible, prepare by overriding the text security to be "none". + \
This can only happen as a result of either a setStyle call (which will be followed by \
a call to updateFromElement) or from createSubtreeIfNeeded, which + is called \
directly from updateFromElement. updateFromElement will immediately update the text \
displayed. + (WebCore::RenderTextControl::updateFromElement): If the \
placeholder visibility has changed, update the text that is displayed. + \
(WebCore::RenderTextControl::forwardEvent): Remove calls to update the placeholder \
state. This is now done in HTMLInputElement. + * \
rendering/RenderTextControl.h: +
</ins><span class="cx"> 2008-09-30 Beth Dakin <bdakin@apple.com>
</span><span class="cx">
</span><span class="cx"> Reviewed by Darin Adler.
</span></span></pre></div>
<a id="trunkWebCorecssCSSSelectorcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/css/CSSSelector.cpp (37122 => \
37123)</h4> <pre class="diff"><span>
<span class="info">--- trunk/WebCore/css/CSSSelector.cpp 2008-09-30 23:19:53 UTC (rev \
37122)
+++ trunk/WebCore/css/CSSSelector.cpp 2008-09-30 23:21:50 UTC (rev 37123)
</span><span class="lines">@@ -88,6 +88,7 @@
</span><span class="cx"> static AtomicString focus("focus");
</span><span class="cx"> static AtomicString hover("hover");
</span><span class="cx"> static AtomicString \
indeterminate("indeterminate"); </span><ins>+ static AtomicString \
inputPlaceholderMode("-webkit-input-placeholder-mode"); </ins><span \
class="cx"> static AtomicString lastChild("last-child"); </span><span \
class="cx"> static AtomicString lastOfType("last-of-type"); \
</span><span class="cx"> static AtomicString link("link"); </span><span \
class="lines">@@ -152,6 +153,8 @@ </span><span class="cx"> m_pseudoType = \
PseudoFirstChild; </span><span class="cx"> else if (m_value == fullPageMedia)
</span><span class="cx"> m_pseudoType = PseudoFullPageMedia;
</span><ins>+ else if (m_value == inputPlaceholderMode)
+ m_pseudoType = PseudoInputPlaceholderMode;
</ins><span class="cx"> else if (m_value == lastChild)
</span><span class="cx"> m_pseudoType = PseudoLastChild;
</span><span class="cx"> else if (m_value == lastOfType)
</span></span></pre></div>
<a id="trunkWebCorecssCSSSelectorh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/css/CSSSelector.h (37122 => \
37123)</h4> <pre class="diff"><span>
<span class="info">--- trunk/WebCore/css/CSSSelector.h 2008-09-30 23:19:53 UTC (rev \
37122)
+++ trunk/WebCore/css/CSSSelector.h 2008-09-30 23:21:50 UTC (rev 37123)
</span><span class="lines">@@ -140,6 +140,7 @@
</span><span class="cx"> PseudoEnabled,
</span><span class="cx"> PseudoFullPageMedia,
</span><span class="cx"> PseudoDisabled,
</span><ins>+ PseudoInputPlaceholderMode,
</ins><span class="cx"> PseudoReadOnly,
</span><span class="cx"> PseudoReadWrite,
</span><span class="cx"> PseudoIndeterminate,
</span></span></pre></div>
<a id="trunkWebCorecssCSSStyleSelectorcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/css/CSSStyleSelector.cpp (37122 => \
37123)</h4> <pre class="diff"><span>
<span class="info">--- trunk/WebCore/css/CSSStyleSelector.cpp 2008-09-30 23:19:53 UTC \
(rev 37122)
+++ trunk/WebCore/css/CSSStyleSelector.cpp 2008-09-30 23:21:50 UTC (rev 37123)
</span><span class="lines">@@ -2191,6 +2191,10 @@
</span><span class="cx"> // that are non-"hidden" \
controls. </span><span class="cx"> return !e->isEnabled(); \
</span><span class="cx"> break;
</span><ins>+ case CSSSelector::PseudoInputPlaceholderMode:
+ if (e && e->hasTagName(inputTag))
+ return \
static_cast<HTMLInputElement*>(e)->placeholderShouldBeVisible(); + \
break; </ins><span class="cx"> case CSSSelector::PseudoReadOnly:
</span><span class="cx"> return e && e->isTextControl() \
&& e->isReadOnlyControl(); </span><span class="cx"> case \
CSSSelector::PseudoReadWrite: </span></span></pre></div>
<a id="trunkWebCorecsshtml4css"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/css/html4.css (37122 => 37123)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/css/html4.css 2008-09-30 23:19:53 UTC (rev \
37122)
+++ trunk/WebCore/css/html4.css 2008-09-30 23:21:50 UTC (rev 37123)
</span><span class="lines">@@ -361,6 +361,10 @@
</span><span class="cx"> cursor: auto;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+input:-webkit-input-placeholder-mode {
+ color: darkGray;
+}
+
</ins><span class="cx"> input[type="password"] {
</span><span class="cx"> -webkit-text-security: disc !important;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkWebCorehtmlHTMLInputElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/html/HTMLInputElement.cpp (37122 => \
37123)</h4> <pre class="diff"><span>
<span class="info">--- trunk/WebCore/html/HTMLInputElement.cpp 2008-09-30 23:19:53 \
UTC (rev 37122)
+++ trunk/WebCore/html/HTMLInputElement.cpp 2008-09-30 23:21:50 UTC (rev 37123)
</span><span class="lines">@@ -127,7 +127,8 @@
</span><span class="cx"> m_autocomplete = Uninitialized;
</span><span class="cx"> m_inited = false;
</span><span class="cx"> m_autofilled = false;
</span><del>-
</del><ins>+ m_placeholderShouldBeVisible = false;
+
</ins><span class="cx"> xPos = 0;
</span><span class="cx"> yPos = 0;
</span><span class="cx">
</span><span class="lines">@@ -245,6 +246,7 @@
</span><span class="cx"> {
</span><span class="cx"> if (isTextField()) {
</span><span class="cx"> setAutofilled(false);
</span><ins>+ updatePlaceholderVisibility();
</ins><span class="cx"> if (inputType() == PASSWORD && \
document()->frame()) </span><span class="cx"> \
document()->setUseSecureKeyboardEntryWhenActive(true); </span><span class="cx"> \
} </span><span class="lines">@@ -254,6 +256,7 @@
</span><span class="cx"> void HTMLInputElement::dispatchBlurEvent()
</span><span class="cx"> {
</span><span class="cx"> if (isTextField() && document()->frame()) {
</span><ins>+ updatePlaceholderVisibility();
</ins><span class="cx"> if (inputType() == PASSWORD)
</span><span class="cx"> \
document()->setUseSecureKeyboardEntryWhenActive(false); </span><span class="cx"> \
document()->frame()->textFieldDidEndEditing(this); </span><span \
class="lines">@@ -689,9 +692,10 @@ </span><span class="cx"> attach();
</span><span class="cx"> }
</span><span class="cx"> setChanged();
</span><del>- } else if (attr->name() == autosaveAttr ||
</del><ins>+ } else if (attr->name() == placeholderAttr)
+ updatePlaceholderVisibility();
+ else if (attr->name() == autosaveAttr ||
</ins><span class="cx"> attr->name() == incrementalAttr ||
</span><del>- attr->name() == placeholderAttr ||
</del><span class="cx"> attr->name() == minAttr ||
</span><span class="cx"> attr->name() == maxAttr ||
</span><span class="cx"> attr->name() == precisionAttr) {
</span><span class="lines">@@ -995,6 +999,8 @@
</span><span class="cx"> if (inputType() == FILE && !value.isEmpty())
</span><span class="cx"> return;
</span><span class="cx">
</span><ins>+ updatePlaceholderVisibility();
+
</ins><span class="cx"> setValueMatchesRenderer(false);
</span><span class="cx"> if (storesValueSeparateFromAttribute()) {
</span><span class="cx"> if (inputType() == FILE)
</span><span class="lines">@@ -1026,6 +1032,8 @@
</span><span class="cx"> // Renderer and our event handler are responsible for \
constraining values. </span><span class="cx"> ASSERT(value == \
constrainValue(value) || constrainValue(value).isEmpty()); </span><span class="cx">
</span><ins>+ updatePlaceholderVisibility();
+
</ins><span class="cx"> if (inputType() == FILE) {
</span><span class="cx"> m_fileList->clear();
</span><span class="cx"> m_fileList->append(File::create(value));
</span><span class="lines">@@ -1550,6 +1558,18 @@
</span><span class="cx"> \
document()->unregisterForDocumentActivationCallbacks(this); </span><span \
class="cx"> } </span><span class="cx">
</span><ins>+void HTMLInputElement::updatePlaceholderVisibility()
+{
+ bool oldPlaceholderShouldBeVisible = m_placeholderShouldBeVisible;
+
+ m_placeholderShouldBeVisible = value().isEmpty()
+ && document()->focusedNode() != this
+ && !getAttribute(placeholderAttr).isEmpty();
+
+ if (oldPlaceholderShouldBeVisible != m_placeholderShouldBeVisible)
+ setChanged();
+}
+
</ins><span class="cx"> String HTMLInputElement::constrainValue(const String& \
proposedValue, int maxLen) const </span><span class="cx"> {
</span><span class="cx"> if (isTextField()) {
</span></span></pre></div>
<a id="trunkWebCorehtmlHTMLInputElementh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/html/HTMLInputElement.h (37122 => \
37123)</h4> <pre class="diff"><span>
<span class="info">--- trunk/WebCore/html/HTMLInputElement.h 2008-09-30 23:19:53 UTC \
(rev 37122)
+++ trunk/WebCore/html/HTMLInputElement.h 2008-09-30 23:21:50 UTC (rev 37123)
</span><span class="lines">@@ -204,6 +204,8 @@
</span><span class="cx">
</span><span class="cx"> virtual bool willValidate() const;
</span><span class="cx">
</span><ins>+ bool placeholderShouldBeVisible() const { return \
m_placeholderShouldBeVisible; } +
</ins><span class="cx"> protected:
</span><span class="cx"> virtual void willMoveToNewOwnerDocument();
</span><span class="cx"> virtual void didMoveToNewOwnerDocument();
</span><span class="lines">@@ -220,6 +222,8 @@
</span><span class="cx"> void registerForActivationCallbackIfNeeded();
</span><span class="cx"> void unregisterForActivationCallbackIfNeeded();
</span><span class="cx">
</span><ins>+ void updatePlaceholderVisibility();
+
</ins><span class="cx"> String m_value;
</span><span class="cx"> String m_originalValue;
</span><span class="cx"> int xPos;
</span><span class="lines">@@ -243,6 +247,7 @@
</span><span class="cx"> AutoCompleteSetting m_autocomplete : 2;
</span><span class="cx"> bool m_autofilled : 1;
</span><span class="cx"> bool m_inited : 1;
</span><ins>+ bool m_placeholderShouldBeVisible : 1;
</ins><span class="cx">
</span><span class="cx"> int cachedSelStart;
</span><span class="cx"> int cachedSelEnd;
</span></span></pre></div>
<a id="trunkWebCorerenderingRenderTextControlcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/rendering/RenderTextControl.cpp \
(37122 => 37123)</h4> <pre class="diff"><span>
<span class="info">--- trunk/WebCore/rendering/RenderTextControl.cpp 2008-09-30 \
23:19:53 UTC (rev 37122)
+++ trunk/WebCore/rendering/RenderTextControl.cpp 2008-09-30 23:21:50 UTC (rev 37123)
</span><span class="lines">@@ -58,6 +58,28 @@
</span><span class="cx"> using namespace EventNames;
</span><span class="cx"> using namespace HTMLNames;
</span><span class="cx">
</span><ins>+// Value chosen by observation. This can be tweaked.
+static const int minColorContrastValue = 1300;
+
+static Color disabledTextColor(const Color& textColor, const Color& \
backgroundColor) +{
+ // The explicit check for black is an optimization for the 99% case (black on \
white). + // This also means that black on black will turn into grey on black when \
disabled. + Color disabledColor;
+ if (textColor.rgb() == Color::black || differenceSquared(textColor, \
Color::white) > differenceSquared(backgroundColor, Color::white)) + \
disabledColor = textColor.light(); + else
+ disabledColor = textColor.dark();
+
+ // If there's not very much contrast between the disabled color and the \
background color, + // just leave the text color alone. We don't want to change a \
good contrast color scheme so that it has really bad contrast. + // If the the \
contrast was already poor, then it doesn't do any good to change it to a different \
poor contrast color scheme. + if (differenceSquared(disabledColor, \
backgroundColor) < minColorContrastValue) + return textColor;
+
+ return disabledColor;
+}
+
</ins><span class="cx"> RenderTextControl::RenderTextControl(Node* node, bool \
multiLine) </span><span class="cx"> : RenderBlock(node)
</span><span class="cx"> , m_dirty(false)
</span><span class="lines">@@ -120,15 +142,6 @@
</span><span class="cx"> setReplaced(isInline());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static Color disabledTextColor(const Color& textColor, const \
Color& backgroundColor)
-{
- // The explcit check for black is an optimization for the 99% case (black on \
white).
- // This also means that black on black will turn into grey on black when \
disabled.
- if (textColor.rgb() == Color::black || differenceSquared(textColor, \
Color::white) > differenceSquared(backgroundColor, Color::white))
- return textColor.light();
- return textColor.dark();
-}
-
</del><span class="cx"> RenderStyle* \
RenderTextControl::createInnerBlockStyle(RenderStyle* startStyle) </span><span \
class="cx"> { </span><span class="cx"> RenderStyle* innerBlockStyle = new \
(renderArena()) RenderStyle(); </span><span class="lines">@@ -190,6 +203,12 @@
</span><span class="cx"> textBlockStyle->setPaddingLeft(Length(3, Fixed));
</span><span class="cx"> textBlockStyle->setPaddingRight(Length(3, \
Fixed)); </span><span class="cx"> }
</span><ins>+
+ // When the placeholder is going to be displayed, temporarily override the text \
security to be "none". + // After this, updateFromElement will \
immediately update the text displayed. + // When the placeholder is no longer \
visible, style will be recomputed, and the text security mode will be set back to the \
computed value correctly. + if (!m_multiLine && \
static_cast<HTMLInputElement*>(element)->placeholderShouldBeVisible()) + \
textBlockStyle->setTextSecurity(TSNONE); </ins><span class="cx">
</span><span class="cx"> if (!element->isEnabled())
</span><span class="cx"> \
textBlockStyle->setColor(disabledTextColor(startStyle->color(), \
startStyle->backgroundColor())); </span><span class="lines">@@ -236,50 +255,6 @@
</span><span class="cx"> return cancelBlockStyle;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void RenderTextControl::updatePlaceholder()
-{
- bool oldPlaceholderVisible = m_placeholderVisible;
-
- String placeholder;
- if (!m_multiLine) {
- HTMLInputElement* input = static_cast<HTMLInputElement*>(node());
- if (input->value().isEmpty() && document()->focusedNode() != \
node())
- placeholder = input->getAttribute(placeholderAttr);
- }
-
- if (!placeholder.isEmpty() || m_placeholderVisible) {
- ExceptionCode ec = 0;
- m_innerText->setInnerText(placeholder, ec);
- m_placeholderVisible = !placeholder.isEmpty();
- }
-
- Color color;
- if (!placeholder.isEmpty())
- color = Color::darkGray;
- else if (node()->isEnabled())
- color = style()->color();
- else
- color = disabledTextColor(style()->color(), \
style()->backgroundColor());
-
- RenderObject* renderer = m_innerText->renderer();
- RenderStyle* innerStyle = renderer->style();
- if (innerStyle->color() != color) {
- innerStyle->setColor(color);
- renderer->repaint();
- }
-
- // temporary disable textSecurity if placeholder is visible
- if (style()->textSecurity() != TSNONE && oldPlaceholderVisible != \
m_placeholderVisible) {
- RenderStyle* newInnerStyle = new (renderArena()) RenderStyle(*innerStyle);
- newInnerStyle->setTextSecurity(m_placeholderVisible ? TSNONE : \
style()->textSecurity());
- renderer->setStyle(newInnerStyle);
- for (Node* n = m_innerText->firstChild(); n; n = \
n->traverseNextNode(m_innerText.get())) {
- if (n->renderer())
- n->renderer()->setStyle(newInnerStyle);
- }
- }
-}
-
</del><span class="cx"> void RenderTextControl::createSubtreeIfNeeded()
</span><span class="cx"> {
</span><span class="cx"> bool isSearchField = !m_multiLine && \
static_cast<HTMLInputElement*>(node())->isSearchField(); </span><span \
class="lines">@@ -327,16 +302,21 @@ </span><span class="cx"> {
</span><span class="cx"> HTMLFormControlElement* element = \
static_cast<HTMLFormControlElement*>(node()); </span><span class="cx">
</span><ins>+ bool placeholderShouldBeVisible = !m_multiLine && \
static_cast<HTMLInputElement*>(element)->placeholderShouldBeVisible(); + \
bool placeholderVisibilityShouldChange = m_placeholderVisible != \
placeholderShouldBeVisible; + m_placeholderVisible = placeholderShouldBeVisible;
+
</ins><span class="cx"> createSubtreeIfNeeded();
</span><span class="cx">
</span><span class="cx"> if (m_cancelButton && \
m_cancelButton->renderer()) </span><span class="cx"> \
updateCancelButtonVisibility(m_cancelButton->renderer()->style()); </span><span \
class="cx"> </span><del>- updatePlaceholder();
-
</del><span class="cx"> \
m_innerText->renderer()->style()->setUserModify(element->isReadOnlyControl() \
|| element->disabled() ? READ_ONLY : READ_WRITE_PLAINTEXT_ONLY); </span><del>-
- if ((!element->valueMatchesRenderer() || m_multiLine) && \
!m_placeholderVisible) { </del><ins>+
+ if (m_placeholderVisible) {
+ ExceptionCode ec;
+ m_innerText->setInnerText(static_cast<HTMLInputElement*>(element)->getAttribute(placeholderAttr), \
ec); + } else if (!element->valueMatchesRenderer() || m_multiLine || \
placeholderVisibilityShouldChange) { </ins><span class="cx"> String value;
</span><span class="cx"> if (m_multiLine)
</span><span class="cx"> value = \
static_cast<HTMLTextAreaElement*>(element)->value(); </span><span \
class="lines">@@ -871,12 +851,10 @@ </span><span class="cx"> if \
(innerLayer && !m_multiLine) </span><span class="cx"> \
innerLayer->scrollToOffset(style()->direction() == RTL ? \
innerLayer->scrollWidth() : 0, 0); </span><span class="cx"> }
</span><del>- updatePlaceholder();
</del><span class="cx"> capsLockStateMayHaveChanged();
</span><del>- } else if (evt->type() == focusEvent) {
- updatePlaceholder();
</del><ins>+ } else if (evt->type() == focusEvent)
</ins><span class="cx"> capsLockStateMayHaveChanged();
</span><del>- } else {
</del><ins>+ else {
</ins><span class="cx"> if (evt->isMouseEvent() && m_resultsButton \
&& static_cast<MouseEvent*>(evt)->x() < \
m_innerText->renderer()->absoluteBoundingBoxRect().x()) </span><span \
class="cx"> m_resultsButton->defaultEventHandler(evt); </span><span \
class="cx"> else if (evt->isMouseEvent() && m_cancelButton \
&& static_cast<MouseEvent*>(evt)->x() > \
m_innerText->renderer()->absoluteBoundingBoxRect().right()) \
</span></span></pre></div> <a id="trunkWebCorerenderingRenderTextControlh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/rendering/RenderTextControl.h (37122 \
=> 37123)</h4> <pre class="diff"><span>
<span class="info">--- trunk/WebCore/rendering/RenderTextControl.h 2008-09-30 \
23:19:53 UTC (rev 37122)
+++ trunk/WebCore/rendering/RenderTextControl.h 2008-09-30 23:21:50 UTC (rev 37123)
</span><span class="lines">@@ -134,7 +134,6 @@
</span><span class="cx"> RenderStyle* createCancelButtonStyle(RenderStyle* \
startStyle); </span><span class="cx"> RenderStyle* \
createResultsButtonStyle(RenderStyle* startStyle); </span><span class="cx">
</span><del>- void updatePlaceholder();
</del><span class="cx"> void createSubtreeIfNeeded();
</span><span class="cx"> void updateCancelButtonVisibility(RenderStyle*);
</span><span class="cx"> const AtomicString& autosaveName() const;
</span></span></pre>
</div>
</div>
</body>
</html>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic