<http://webkit.org/b/49848> Make it possible to display the last character of a secur...
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 20 Nov 2010 18:54:43 +0000 (18:54 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 20 Nov 2010 18:54:43 +0000 (18:54 +0000)
Reviewed by Darin Adler.

* JavaScriptCore.exp:
* wtf/text/StringImpl.cpp:
(WTF::StringImpl::secure): Added argument that controls whether
the last character is obscured or not.  Implemented behavior.
* wtf/text/StringImpl.h:
(WTF::StringImpl::LastCharacterBehavior): Added enum.
(WTF::StringImpl::secure): Updated method signature.

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

JavaScriptCore/ChangeLog
JavaScriptCore/JavaScriptCore.exp
JavaScriptCore/wtf/text/StringImpl.cpp
JavaScriptCore/wtf/text/StringImpl.h

index 1022d3578bf10815d69079a9c8380812bcfcab68..80d0edbdbb67c681328a6c744a412a9c1b25318c 100644 (file)
@@ -1,3 +1,17 @@
+2010-11-20  David Kilzer  <ddkilzer@apple.com>
+
+        <http://webkit.org/b/49848> Make it possible to display the last character of a secure text field unobscured
+
+        Reviewed by Darin Adler.
+
+        * JavaScriptCore.exp:
+        * wtf/text/StringImpl.cpp:
+        (WTF::StringImpl::secure): Added argument that controls whether
+        the last character is obscured or not.  Implemented behavior.
+        * wtf/text/StringImpl.h:
+        (WTF::StringImpl::LastCharacterBehavior): Added enum.
+        (WTF::StringImpl::secure): Updated method signature.
+
 2010-11-19  William Chan  <willchan@chromium.org>
 
         Reviewed by David Levin.
index 3715a43837dc910e8de70e433ed26feb154180d3..ac5d0d7cef41c8a95655d0fdbb4be0df4379dc9c 100644 (file)
@@ -350,7 +350,7 @@ __ZN3WTF10StringImpl5upperEv
 __ZN3WTF10StringImpl6createEPKc
 __ZN3WTF10StringImpl6createEPKcj
 __ZN3WTF10StringImpl6createEPKtj
-__ZN3WTF10StringImpl6secureEt
+__ZN3WTF10StringImpl6secureEtNS0_21LastCharacterBehaviorE
 __ZN3WTF10StringImpl7replaceEPS0_S1_
 __ZN3WTF10StringImpl7replaceEjjPS0_
 __ZN3WTF10StringImpl7replaceEtPS0_
index 1c4de660812f2c5fe7ca83e0da3e1084bec1baa0..c83ec42ac1d68f8d72f07459aa42f56aa06f744d 100644 (file)
@@ -270,12 +270,17 @@ PassRefPtr<StringImpl> StringImpl::upper()
     return newImpl.release();
 }
 
-PassRefPtr<StringImpl> StringImpl::secure(UChar character)
+PassRefPtr<StringImpl> StringImpl::secure(UChar character, LastCharacterBehavior behavior)
 {
+    if (!m_length)
+        return this;
+
     UChar* data;
     RefPtr<StringImpl> newImpl = createUninitialized(m_length, data);
-    for (unsigned i = 0; i < m_length; ++i)
+    unsigned lastCharacterIndex = m_length - 1;
+    for (unsigned i = 0; i < lastCharacterIndex; ++i)
         data[i] = character;
+    data[lastCharacterIndex] = (behavior == ObscureLastCharacter) ? character : m_data[lastCharacterIndex];
     return newImpl.release();
 }
 
index 8f0af52480bbc981d545886b2d1996ac27c8ddd1..99d0e9d416d5527babfcddd8b8c977c7f8896091 100644 (file)
@@ -284,7 +284,10 @@ public:
 
     PassRefPtr<StringImpl> lower();
     PassRefPtr<StringImpl> upper();
-    PassRefPtr<StringImpl> secure(UChar aChar);
+
+    enum LastCharacterBehavior { ObscureLastCharacter, DisplayLastCharacter };
+
+    PassRefPtr<StringImpl> secure(UChar, LastCharacterBehavior = ObscureLastCharacter);
     PassRefPtr<StringImpl> foldCase();
 
     PassRefPtr<StringImpl> stripWhiteSpace();