Reviewed by Anders.
authoradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 2 Sep 2006 17:25:46 +0000 (17:25 +0000)
committeradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 2 Sep 2006 17:25:46 +0000 (17:25 +0000)
        - Fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=10667
          Password: Double-click should select-all to avoid exposing word boundaries

        Test: fast/forms/password-doubleclick-selection.html

        * editing/visible_units.cpp:
        (WebCore::previousBoundary): When searching for boundaries in renderers that use the textSecurity property,
         convert characters in strings to alpha-numeric characters (in this case, all 'x's) so that every character
         isn't treated as a punctuation boundary.
        (WebCore::nextBoundary): ditto.
        * editing/TextIterator.cpp: (WebCore::SimplifiedBackwardsTextIterator::handleTextNode): Updated to use the renderer's
          string instead of the node value.  This matches the base class implementation of handleTextNode.

        Code cleanup.
        * editing/ReplaceSelectionCommand.cpp: (WebCore::ReplaceSelectionCommand::doApply):
          Avoid unnecessary check for password field case if the smart replace condition is false.
        * page/Frame.cpp: (WebCore::Frame::mayCopy): Removed duplicate code.  Calls isSelectionInPasswordField now.
        * rendering/RenderText.cpp: (WebCore::RenderText::setText): Updated formatting.

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

WebCore/ChangeLog
WebCore/editing/ReplaceSelectionCommand.cpp
WebCore/editing/TextIterator.cpp
WebCore/editing/visible_units.cpp
WebCore/page/Frame.cpp
WebCore/rendering/RenderText.cpp

index ecb5c5542df11939fa41446d8f8cbdfef52bc59d..7d57632fe9f0be35fbd2ee2d2d0bd9781e2eb492 100644 (file)
@@ -1,3 +1,26 @@
+2006-09-02  Adele Peterson  <adele@apple.com>
+
+        Reviewed by Anders.
+
+        - Fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=10667
+          Password: Double-click should select-all to avoid exposing word boundaries
+
+        Test: fast/forms/password-doubleclick-selection.html
+
+        * editing/visible_units.cpp:
+        (WebCore::previousBoundary): When searching for boundaries in renderers that use the textSecurity property, 
+         convert characters in strings to alpha-numeric characters (in this case, all 'x's) so that every character
+         isn't treated as a punctuation boundary.
+        (WebCore::nextBoundary): ditto.
+        * editing/TextIterator.cpp: (WebCore::SimplifiedBackwardsTextIterator::handleTextNode): Updated to use the renderer's 
+          string instead of the node value.  This matches the base class implementation of handleTextNode.
+
+        Code cleanup.
+        * editing/ReplaceSelectionCommand.cpp: (WebCore::ReplaceSelectionCommand::doApply): 
+          Avoid unnecessary check for password field case if the smart replace condition is false.
+        * page/Frame.cpp: (WebCore::Frame::mayCopy): Removed duplicate code.  Calls isSelectionInPasswordField now.
+        * rendering/RenderText.cpp: (WebCore::RenderText::setText): Updated formatting.
+
 2006-09-01  David Hyatt  <hyatt@apple.com>
 
         Fix for 10682, refine the FOUC paint suppression logic so that it
index 507dc3e3ac80e7c1397e0a7f0b75e17de473e311..124474295ccb681569b66e61194a3f6b0aeb96cf 100644 (file)
@@ -637,13 +637,13 @@ void ReplaceSelectionCommand::doApply()
     endOfInsertedContent = VisiblePosition(Position(m_lastNodeInserted.get(), maxDeepOffset(m_lastNodeInserted.get())));
     startOfInsertedContent = VisiblePosition(Position(m_firstNodeInserted.get(), 0));    
     
-    if (currentRoot) {
+    // Add spaces for smart replace.
+    if (m_smartReplace && currentRoot) {
         // Disable smart replace for password fields.
         Node* start = currentRoot->shadowAncestorNode();
         if (start->hasTagName(inputTag) && static_cast<HTMLInputElement*>(start)->inputType() == HTMLInputElement::PASSWORD)
             m_smartReplace = false;
     }
-    // Add spaces for smart replace.
     if (m_smartReplace) {
         bool needsTrailingSpace = !isEndOfParagraph(endOfInsertedContent) &&
                                   !frame->isCharacterSmartReplaceExempt(endOfInsertedContent.characterAfter(), false);
index 966ad2b4d25ea0daae415feea7d7b5cc6b11e089..cc97735cac4e1df522d9eef439f0ce832a47ff41 100644 (file)
@@ -678,7 +678,7 @@ bool SimplifiedBackwardsTextIterator::handleTextNode()
     m_lastTextNode = m_node;
 
     RenderText *renderer = static_cast<RenderText *>(m_node->renderer());
-    String str = m_node->nodeValue();
+    String str = renderer->string();
 
     if (!renderer->firstTextBox() && str.length() > 0)
         return true;
index 4ed0c2efbeec869c4e256bbae6d50422afecc3e7..0dcea605f4ef957db73038773a9b7f63ae20f504 100644 (file)
@@ -70,9 +70,14 @@ static VisiblePosition previousBoundary(const VisiblePosition &c, unsigned (*sea
     SimplifiedBackwardsTextIterator it(searchRange.get());
     DeprecatedString string;
     unsigned next = 0;
+    bool inTextSecurityMode = start.node() && start.node()->renderer() && start.node()->renderer()->style()->textSecurity() != TSNONE;
     while (!it.atEnd() && it.length() > 0) {
         // iterate to get chunks until the searchFunction returns a non-zero value.
-        string.prepend(reinterpret_cast<const DeprecatedChar*>(it.characters()), it.length());
+        String iteratorString(it.characters(), it.length());
+        // Treat bullets used in the text security mode as regular characters when looking for boundaries
+        if (inTextSecurityMode)
+            iteratorString = iteratorString.impl()->secure('x');
+        string.prepend(iteratorString.deprecatedString());
         next = searchFunction(reinterpret_cast<const UChar*>(string.unicode()), string.length());
         if (next != 0)
             break;
@@ -140,10 +145,15 @@ static VisiblePosition nextBoundary(const VisiblePosition &c, unsigned (*searchF
     TextIterator it(searchRange.get(), RUNFINDER);
     DeprecatedString string;
     unsigned next = 0;
+    bool inTextSecurityMode = start.node() && start.node()->renderer() && start.node()->renderer()->style()->textSecurity() != TSNONE;
     while (!it.atEnd() && it.length() > 0) {
         // Keep asking the iterator for chunks until the search function
         // returns an end value not equal to the length of the string passed to it.
-        string.append(reinterpret_cast<const DeprecatedChar*>(it.characters()), it.length());
+        String iteratorString(it.characters(), it.length());
+        // Treat bullets used in the text security mode as regular characters when looking for boundaries
+        if (inTextSecurityMode)
+            iteratorString = iteratorString.impl()->secure('x');
+        string.append(iteratorString.deprecatedString());
         next = searchFunction(reinterpret_cast<const UChar*>(string.unicode()), string.length());
         if (next != string.length())
             break;
index 8cd155981434cbe9f2e95070de840f94c45498b4..5cf13cd13be7b19e8672d5b0599b9367d343dd28 100644 (file)
@@ -2189,13 +2189,7 @@ void Frame::pasteAndMatchStyle()
 
 bool Frame::mayCopy()
 {
-    Node* startNode = selection().start().node();
-    if (startNode) {
-        startNode = startNode->shadowAncestorNode();
-        if (startNode->hasTagName(inputTag) && static_cast<HTMLInputElement*>(startNode)->inputType() == HTMLInputElement::PASSWORD)
-            return false;
-    }
-    return true;
+    return !isSelectionInPasswordField();
 }
 
 void Frame::transpose()
index 5a7c901538cafc4aa0c984e741d075dbdbf38856..fd2468b6faed8c1f00db4969cd900fdec5ebc771 100644 (file)
@@ -913,16 +913,15 @@ void RenderText::setText(StringImpl *text, bool force)
                 default:;
             }
             
-            switch(style()->textSecurity())
-            {
+            switch(style()->textSecurity()) {
                 case TSDISC:
-                    str= str->secure(BULLET_CHAR);
+                    str = str->secure(BULLET_CHAR);
                     break;
                 case TSCIRCLE:
-                    str= str->secure(CIRCLE_CHAR);
+                    str = str->secure(CIRCLE_CHAR);
                     break;
                 case TSSQUARE: 
-                    str= str->secure(SQUARE_CHAR);
+                    str = str->secure(SQUARE_CHAR);
                     break;
                 case TSNONE:
                     break;