LayoutTests:
authoradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 26 Aug 2006 00:33:22 +0000 (00:33 +0000)
committeradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 26 Aug 2006 00:33:22 +0000 (00:33 +0000)
        Updated results for addition of -webkit-text-security.

        * fast/css/computed-style-expected.txt:

WebCore:

        Patch by Francisco, Reviewed by me.

        Preparation for switch to new text field implementation of password field.

        Added -webkit-text-security property.

        Tests: updated fast/css/computed-style-expected.txt

        * css/CSSPropertyNames.in: Added -webkit-text-security.
        * css/CSSComputedStyleDeclaration.cpp:
        (WebCore::):
        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Added cases for textSecurity.
        * css/cssparser.cpp: (WebCore::CSSParser::parseValue): ditto.
        * css/cssstyleselector.cpp: (WebCore::CSSStyleSelector::applyProperty): ditto.
        * css/html4.css: Added style for password field to use -webkit-text-security.

        * html/HTMLInputElement.cpp: Check appearance property to decide which renderer to use.
        (WebCore::HTMLInputElement::selectionStart):
        (WebCore::HTMLInputElement::selectionEnd):
        (WebCore::HTMLInputElement::setSelectionStart):
        (WebCore::HTMLInputElement::setSelectionEnd):
        (WebCore::HTMLInputElement::select):
        (WebCore::HTMLInputElement::setSelectionRange):
        (WebCore::HTMLInputElement::createRenderer):
        * html/HTMLInputElement.h: (WebCore::HTMLInputElement::isNonWidgetTextField): Added check for password.

        * platform/StringImpl.cpp: (WebCore::StringImpl::secure): Added. Converts a string to replace
         characters with one character, like a bullet.
        * platform/StringImpl.h:

        * rendering/RenderStyle.cpp:
        (WebCore::StyleCSS3InheritedData::StyleCSS3InheritedData): Initialize textSecurity.
        (WebCore::RenderStyle::diff): Added case for textSecurity.
        * rendering/RenderStyle.h:
        (WebCore::):
        (WebCore::RenderStyle::textSecurity): Added.
        (WebCore::RenderStyle::setTextSecurity): Added.
        (WebCore::RenderStyle::initialTextSecurity): Added.
        * rendering/RenderText.cpp:
        (WebCore::RenderText::setStyle): Added case for textSecurity.
        (WebCore::RenderText::setText): ditto.

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

15 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/computed-style-expected.txt
WebCore/ChangeLog
WebCore/css/CSSComputedStyleDeclaration.cpp
WebCore/css/CSSPropertyNames.in
WebCore/css/cssparser.cpp
WebCore/css/cssstyleselector.cpp
WebCore/css/html4.css
WebCore/html/HTMLInputElement.cpp
WebCore/html/HTMLInputElement.h
WebCore/platform/StringImpl.cpp
WebCore/platform/StringImpl.h
WebCore/rendering/RenderStyle.cpp
WebCore/rendering/RenderStyle.h
WebCore/rendering/RenderText.cpp

index 65f4ba8646243ca44167072caf9ed378bab916e6..b5986cfdaa4b321bfe3d27891a030a936c1f16c0 100644 (file)
@@ -1,3 +1,9 @@
+2006-08-25  Adele Peterson  <adele@apple.com>
+
+        Updated results for addition of -webkit-text-security.
+
+        * fast/css/computed-style-expected.txt:
+
 2006-08-25  Adele Peterson  <adele@apple.com>
 
         Reviewed by Hyatt.
index 5cc0e610076579959b1b8ba9cff574ddeaac97b8..452d3fe5f7f344d2cc7ee586d1d3319e00c5d237 100644 (file)
@@ -92,6 +92,7 @@ text-decoration: none;
 -webkit-text-decorations-in-effect: none;
 text-indent: 0px;
 text-shadow: none;
+-webkit-text-security: none;
 text-transform: none;
 top: auto;
 unicode-bidi: normal;
index 22a98038194aef1d010bb959a790e1832596b130..79fc1ffd8afd8615fab146fbf2bad5c6b55dc62d 100644 (file)
@@ -1,3 +1,47 @@
+2006-08-25  Adele Peterson  <adele@apple.com>
+
+        Patch by Francisco, Reviewed by me.
+
+        Preparation for switch to new text field implementation of password field.
+
+        Added -webkit-text-security property.
+
+        Tests: updated fast/css/computed-style-expected.txt
+
+        * css/CSSPropertyNames.in: Added -webkit-text-security.
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::):
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Added cases for textSecurity.
+        * css/cssparser.cpp: (WebCore::CSSParser::parseValue): ditto.
+        * css/cssstyleselector.cpp: (WebCore::CSSStyleSelector::applyProperty): ditto.
+        * css/html4.css: Added style for password field to use -webkit-text-security.
+
+        * html/HTMLInputElement.cpp: Check appearance property to decide which renderer to use.
+        (WebCore::HTMLInputElement::selectionStart):
+        (WebCore::HTMLInputElement::selectionEnd):
+        (WebCore::HTMLInputElement::setSelectionStart):
+        (WebCore::HTMLInputElement::setSelectionEnd):
+        (WebCore::HTMLInputElement::select):
+        (WebCore::HTMLInputElement::setSelectionRange):
+        (WebCore::HTMLInputElement::createRenderer):
+        * html/HTMLInputElement.h: (WebCore::HTMLInputElement::isNonWidgetTextField): Added check for password.
+
+        * platform/StringImpl.cpp: (WebCore::StringImpl::secure): Added. Converts a string to replace 
+         characters with one character, like a bullet.
+        * platform/StringImpl.h:
+
+        * rendering/RenderStyle.cpp:
+        (WebCore::StyleCSS3InheritedData::StyleCSS3InheritedData): Initialize textSecurity.
+        (WebCore::RenderStyle::diff): Added case for textSecurity.
+        * rendering/RenderStyle.h:
+        (WebCore::):
+        (WebCore::RenderStyle::textSecurity): Added.
+        (WebCore::RenderStyle::setTextSecurity): Added.
+        (WebCore::RenderStyle::initialTextSecurity): Added.
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::setStyle): Added case for textSecurity.
+        (WebCore::RenderText::setText): ditto.
+
 2006-08-25  Adele Peterson  <adele@apple.com>
 
         Reviewed by Hyatt.
index 2ecba0f7000890e3bd260952b7cad24377c342ae..2919d42a5bde5770c7fbd0262f6167197c062215 100644 (file)
@@ -136,6 +136,7 @@ static const int computedProperties[] = {
     CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT,
     CSS_PROP_TEXT_INDENT,
     CSS_PROP_TEXT_SHADOW,
+    CSS_PROP__WEBKIT_TEXT_SECURITY,
     CSS_PROP_TEXT_TRANSFORM,
     CSS_PROP_TOP,
     CSS_PROP_UNICODE_BIDI,
@@ -1110,6 +1111,21 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         return valueForLength(style->textIndent());
     case CSS_PROP_TEXT_SHADOW:
         return valueForShadow(style->textShadow());
+    case CSS_PROP__WEBKIT_TEXT_SECURITY:
+    {
+        switch (style->textSecurity()) {
+            case TSNONE:
+                return new CSSPrimitiveValue(CSS_VAL_NONE);
+            case TSDISC:
+                return new CSSPrimitiveValue(CSS_VAL_DISC);
+            case TSCIRCLE:
+                return new CSSPrimitiveValue(CSS_VAL_CIRCLE);
+            case TSSQUARE:
+                return new CSSPrimitiveValue(CSS_VAL_SQUARE);
+        }
+        ASSERT_NOT_REACHED();
+        return 0;
+    }
     case CSS_PROP__WEBKIT_TEXT_SIZE_ADJUST:
         if (style->textSizeAdjust()) 
             return new CSSPrimitiveValue(CSS_VAL_AUTO);
index f571eceee645f73d84896c704a53528f8aabbcc6..17a85dc847a3cdf1e2688ef9a208ee9cd7d42f53 100644 (file)
@@ -138,6 +138,7 @@ text-overline-color
 text-overline-mode
 text-overline-style
 text-overline-width
+-webkit-text-security
 text-shadow
 text-transform
 text-underline
index 50bff1f59036adfcbe0274e77b14f7097ec647bd..d7e191955ed1fdc33f8fb9016a6daa661ee65924 100644 (file)
@@ -1175,6 +1175,12 @@ bool CSSParser::parseValue(int propId, bool important)
             valid_primitive = true;
         break;
 
+    case CSS_PROP__WEBKIT_TEXT_SECURITY:
+        // disc | circle | square | none | inherit
+        if (id == CSS_VAL_DISC || id == CSS_VAL_CIRCLE || id == CSS_VAL_SQUARE|| id == CSS_VAL_NONE)
+            valid_primitive = true;
+        break;
+
 #if __APPLE__
     case CSS_PROP__WEBKIT_DASHBOARD_REGION:                 // <dashboard-region> | <dashboard-region> 
         if (value->unit == Value::Function || id == CSS_VAL_NONE)
index 53576deaed24b5b0f109ecdbc9c75074d6b12c98..12832f99772b81e11543d427bbce4a558754ee89 100644 (file)
@@ -4003,6 +4003,21 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         fontDirty = true;
         break;
     }
+    case CSS_PROP__WEBKIT_TEXT_SECURITY: {
+        HANDLE_INHERIT_AND_INITIAL(textSecurity, TextSecurity)
+        if (!primitiveValue) break;
+        ETextSecurity textSecurity= TSNONE;
+        switch(primitiveValue->getIdent())
+        {
+            case CSS_VAL_DISC:      textSecurity= TSDISC;
+                                    break;
+            case CSS_VAL_CIRCLE:    textSecurity= TSCIRCLE;
+                                    break;
+            case CSS_VAL_SQUARE:    textSecurity= TSSQUARE;
+                                    break;
+        }
+        style->setTextSecurity(textSecurity);
+    }
 #if __APPLE__
     case CSS_PROP__WEBKIT_DASHBOARD_REGION: {
         HANDLE_INHERIT_AND_INITIAL(dashboardRegions, DashboardRegions)
index a07370a796a2c12767c2536d4ccaf437346f24c4..2832b958e1aa970e692e010717a76ec99844b076 100644 (file)
@@ -330,7 +330,17 @@ textarea {
     resize: auto;
 }
 
-input[type="password"], input[type="search"], input[type="hidden"], input[type="image"], input[type="file"] {
+input[type="password"] {
+    // FIXME: Remove these when switching over to the new implementation for password fields.    
+    -webkit-appearance:none;
+    background-color: initial;
+    border:initial;
+    padding:initial;
+
+    -webkit-text-security: disc;
+}
+
+input[type="search"], input[type="hidden"], input[type="image"], input[type="file"] {
     -webkit-appearance: initial;
     padding: initial;
     background-color: initial;
@@ -518,7 +528,6 @@ input[type="checkbox"]:focus,
 input[type="file"]:focus,
 input[type="hidden"]:focus,
 input[type="image"]:focus,
-input[type="password"]:focus,
 input[type="radio"]:focus,
 input[type="reset"]:focus,
 input[type="search"]:focus,
index 2263e4a31ddc2c9340f661df7b113e4cb7602a79..38edfb455f1427d2757f0b00c7cb410b2fd3ded3 100644 (file)
@@ -474,13 +474,17 @@ int HTMLInputElement::selectionStart() const
         case RESET:
         case SUBMIT:
             break;
-        case PASSWORD:
         case SEARCH:
             return static_cast<RenderLineEdit*>(renderer())->selectionStart();
         case TEXT:
             if (document()->focusNode() != this && cachedSelStart >= 0)
                 return cachedSelStart;
             return static_cast<RenderTextControl*>(renderer())->selectionStart();
+        case PASSWORD:
+            if (renderer()->style()->appearance() == TextFieldAppearance)
+                return static_cast<RenderTextControl*>(renderer())->selectionStart();
+            else
+                return static_cast<RenderLineEdit*>(renderer())->selectionStart();
     }
     return 0;
 }
@@ -502,13 +506,17 @@ int HTMLInputElement::selectionEnd() const
         case RESET:
         case SUBMIT:
             break;
-        case PASSWORD:
         case SEARCH:
             return static_cast<RenderLineEdit*>(renderer())->selectionEnd();
         case TEXT:
             if (document()->focusNode() != this && cachedSelEnd >= 0)
                 return cachedSelEnd;
             return static_cast<RenderTextControl*>(renderer())->selectionEnd();
+        case PASSWORD:
+            if (renderer()->style()->appearance() == TextFieldAppearance)
+                return static_cast<RenderTextControl*>(renderer())->selectionEnd();
+            else
+                return static_cast<RenderLineEdit*>(renderer())->selectionEnd();
     }
     return 0;
 }
@@ -530,13 +538,18 @@ void HTMLInputElement::setSelectionStart(int start)
         case RESET:
         case SUBMIT:
             break;
-        case PASSWORD:
         case SEARCH:
             static_cast<RenderLineEdit*>(renderer())->setSelectionStart(start);
             break;
         case TEXT:
             static_cast<RenderTextControl*>(renderer())->setSelectionStart(start);
             break;
+        case PASSWORD:
+            if (renderer()->style()->appearance() == TextFieldAppearance)
+                static_cast<RenderTextControl*>(renderer())->setSelectionStart(start);
+            else
+                static_cast<RenderLineEdit*>(renderer())->setSelectionStart(start);
+            break;
     }
 }
 
@@ -557,13 +570,18 @@ void HTMLInputElement::setSelectionEnd(int end)
         case RESET:
         case SUBMIT:
             break;
-        case PASSWORD:
         case SEARCH:
             static_cast<RenderLineEdit*>(renderer())->setSelectionEnd(end);
             break;
         case TEXT:
             static_cast<RenderTextControl*>(renderer())->setSelectionEnd(end);
             break;
+        case PASSWORD:
+            if (renderer()->style()->appearance() == TextFieldAppearance)
+                static_cast<RenderTextControl*>(renderer())->setSelectionEnd(end);
+            else
+                static_cast<RenderLineEdit*>(renderer())->setSelectionEnd(end);
+            break;
     }
 }
 
@@ -586,13 +604,18 @@ void HTMLInputElement::select()
         case FILE:
             static_cast<RenderFileButton*>(renderer())->select();
             break;
-        case PASSWORD:
         case SEARCH:
             static_cast<RenderLineEdit*>(renderer())->select();
             break;
         case TEXT:
             static_cast<RenderTextControl*>(renderer())->select();
             break;
+        case PASSWORD:
+            if (renderer()->style()->appearance() == TextFieldAppearance)
+                static_cast<RenderTextControl*>(renderer())->select();
+            else
+                static_cast<RenderLineEdit*>(renderer())->select();
+            break;
     }
 }
 
@@ -613,13 +636,18 @@ void HTMLInputElement::setSelectionRange(int start, int end)
         case RESET:
         case SUBMIT:
             break;
-        case PASSWORD:
         case SEARCH:
             static_cast<RenderLineEdit*>(renderer())->setSelectionRange(start, end);
             break;
         case TEXT:
             static_cast<RenderTextControl*>(renderer())->setSelectionRange(start, end);
             break;
+        case PASSWORD:
+            if (renderer()->style()->appearance() == TextFieldAppearance)
+                static_cast<RenderTextControl*>(renderer())->setSelectionRange(start, end);
+            else
+                static_cast<RenderLineEdit*>(renderer())->setSelectionRange(start, end);
+            break;
     }
 }
 
@@ -836,13 +864,17 @@ RenderObject *HTMLInputElement::createRenderer(RenderArena *arena, RenderStyle *
         case IMAGE:
             return new (arena) RenderImage(this);
         case ISINDEX:
-        case PASSWORD:
         case SEARCH:
             return new (arena) RenderLineEdit(this);
         case RANGE:
             return new (arena) DeprecatedSlider(this);
         case TEXT:
             return new (arena) RenderTextControl(this, false);
+        case PASSWORD:
+            if (style->appearance() == TextFieldAppearance)
+                return new (arena) RenderTextControl(this, false);
+            else
+                return new (arena) RenderLineEdit(this);                
     }
     assert(false);
     return 0;
index b5e4925107f6f9a4811369299853f8653ea4dfcf..ee0dba61d31c839a5f02aed6969cc2aeae614e73 100644 (file)
 
 #include "HTMLGenericFormElement.h"
 
+// FIXME: Remove these when converting the password field
+#include "RenderStyle.h"
+#include "RenderObject.h"
+
 namespace WebCore {
 
 class HTMLImageLoader;
@@ -81,7 +85,8 @@ public:
     bool isTextField() const { return m_type == TEXT || m_type == PASSWORD || m_type == SEARCH; }
     // FIXME: When other text fields switch to the non-NSView implementation, we should add them here.
     // Once all text fields switch over, we should merge this with isTextField.
-    bool isNonWidgetTextField() const { return m_type == TEXT; }
+    bool isNonWidgetTextField() const { return m_type == TEXT || (m_type == PASSWORD /* FIXME: Remove this style check when converting password */ 
+                                        && renderer() && renderer()->style()->appearance() == TextFieldAppearance); }
 
     bool checked() const { return m_checked; }
     void setChecked(bool, bool sendChangeEvent = false);
index 8acb2b2d6d54daf005f7620b6a0b6e3787803dd7..83c2a748a113c65210b2a81b9562e1138b1638e6 100644 (file)
@@ -461,6 +461,16 @@ StringImpl* StringImpl::upper() const
     return c;
 }
 
+StringImpl* StringImpl::secure(UChar aChar) const
+{
+    StringImpl* c= new StringImpl;
+    c->m_data = newUCharVector(c->m_length= m_length);
+    
+    u_memset(c->m_data, aChar, m_length);
+    
+    return c;
+}
+
 StringImpl* StringImpl::foldCase() const
 {
     StringImpl* c = new StringImpl;
index 90227667bb4347ad60c2a7a947b1bca310fba820..e4bcbd52020f8218cc44f296054a538d59810ca6 100644 (file)
@@ -101,6 +101,7 @@ public:
     bool isLower() const;
     StringImpl* lower() const;
     StringImpl* upper() const;
+    StringImpl* secure(UChar aChar) const;
     StringImpl* capitalize(UChar previousCharacter) const;
     StringImpl* foldCase() const;
 
index 85cbb074aefc760058fb55d721ef3da08b6b1d78..03f857e5566c69d3391ccf2045b3f8fc88a563b7 100644 (file)
@@ -457,6 +457,7 @@ bool StyleCSS3NonInheritedData::operator==(const StyleCSS3NonInheritedData& o) c
 
 StyleCSS3InheritedData::StyleCSS3InheritedData()
     : textShadow(0)
+    , textSecurity(RenderStyle::initialTextSecurity())
     , userModify(READ_ONLY)
     , wordWrap(WBNORMAL)
     , nbspMode(NBNORMAL)
@@ -471,6 +472,7 @@ StyleCSS3InheritedData::StyleCSS3InheritedData(const StyleCSS3InheritedData& o)
     : Shared<StyleCSS3InheritedData>()
     , textShadow(o.textShadow ? new ShadowData(*o.textShadow) : 0)
     , highlight(o.highlight)
+    , textSecurity(o.textSecurity)
     , userModify(o.userModify)
     , wordWrap(o.wordWrap)
     , nbspMode(o.nbspMode)
@@ -835,7 +837,8 @@ RenderStyle::Diff RenderStyle::diff( const RenderStyle *other ) const
          visual->colspan != other->visual->colspan ||
          visual->counter_increment != other->visual->counter_increment ||
          visual->counter_reset != other->visual->counter_reset ||
-         css3NonInheritedData->textOverflow != other->css3NonInheritedData->textOverflow)
+         css3NonInheritedData->textOverflow != other->css3NonInheritedData->textOverflow ||
+         (css3InheritedData->textSecurity != other->css3InheritedData->textSecurity))
         return Layout;
    
     // changes causing Layout changes:
index 263e28a7e4efdf56be74512dc94432dfcb24d719..03bf92159137cd5d1a960b23d0422ac34b08c880 100644 (file)
@@ -654,6 +654,11 @@ struct BindingURI {
 #endif
 
 //------------------------------------------------
+
+enum ETextSecurity {
+    TSNONE, TSDISC, TSCIRCLE, TSSQUARE
+};
+
 // CSS3 User Modify Properties
 
 enum EUserModify {
@@ -764,6 +769,7 @@ public:
 
     ShadowData* textShadow;  // Our text shadow information for shadowed text drawing.
     AtomicString highlight; // Apple-specific extension for custom highlight rendering.
+    unsigned textSecurity : 2; // ETextSecurity
     unsigned userModify : 2; // EUserModify  (editing)
     unsigned wordWrap : 1; // EWordWrap 
     unsigned nbspMode : 1; // ENBSPMode
@@ -1358,6 +1364,7 @@ public:
     // Apple-specific property getter methods
     int lineClamp() const { return css3NonInheritedData->lineClamp; }
     bool textSizeAdjust() const { return css3InheritedData->textSizeAdjust; }
+    ETextSecurity textSecurity() const { return static_cast<ETextSecurity>(css3InheritedData->textSecurity); }
 
 // attribute setter methods
 
@@ -1578,6 +1585,7 @@ public:
     // Apple-specific property setters
     void setLineClamp(int c) { SET_VAR(css3NonInheritedData, lineClamp, c); }
     void setTextSizeAdjust(bool b) { SET_VAR(css3InheritedData, textSizeAdjust, b); }
+    void setTextSecurity(ETextSecurity aTextSecurity) { SET_VAR(css3InheritedData, textSecurity, aTextSecurity); } 
 
 #ifdef SVG_SUPPORT
     const SVGRenderStyle* svgStyle() const { return m_svgStyle.get(); }
@@ -1706,6 +1714,7 @@ public:
     // Keep these at the end.
     static int initialLineClamp() { return -1; }
     static bool initialTextSizeAdjust() { return true; }
+    static ETextSecurity initialTextSecurity() { return TSNONE; }
     static const DeprecatedValueList<StyleDashboardRegion>& initialDashboardRegions();
     static const DeprecatedValueList<StyleDashboardRegion>& noneDashboardRegions();
 };
index 59f334bd6e8c0d659fa244d5f31866f1bca70882..5a7c901538cafc4aa0c984e741d075dbdbf38856 100644 (file)
@@ -111,9 +111,11 @@ void RenderText::setStyle(RenderStyle *_style)
         bool needToTransformText = (!style() && _style->textTransform() != TTNONE) ||
                                    (style() && style()->textTransform() != _style->textTransform());
 
+        bool needToSecureText = (!style() && _style->textSecurity() != TSNONE);
+
         RenderObject::setStyle( _style );
 
-        if (needToTransformText) {
+        if (needToTransformText || needToSecureText) {
             RefPtr<StringImpl> textToTransform = originalString();
             if (textToTransform)
                 setText(textToTransform.get(), true);
@@ -873,6 +875,10 @@ void RenderText::setTextWithOffset(StringImpl *text, unsigned offset, unsigned l
     setText(text, force);
 }
 
+#define BULLET_CHAR 0x2022
+#define SQUARE_CHAR 0x25AA
+#define CIRCLE_CHAR 0x25E6
+
 void RenderText::setText(StringImpl *text, bool force)
 {
     if (!text)
@@ -906,6 +912,21 @@ void RenderText::setText(StringImpl *text, bool force)
                 case NONE:
                 default:;
             }
+            
+            switch(style()->textSecurity())
+            {
+                case TSDISC:
+                    str= str->secure(BULLET_CHAR);
+                    break;
+                case TSCIRCLE:
+                    str= str->secure(CIRCLE_CHAR);
+                    break;
+                case TSSQUARE: 
+                    str= str->secure(SQUARE_CHAR);
+                    break;
+                case TSNONE:
+                    break;
+            }
         }
     }