Address the review comments for r163825.
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Feb 2014 01:56:31 +0000 (01:56 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Feb 2014 01:56:31 +0000 (01:56 +0000)
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::indexForVisiblePosition):
(WebCore::positionForIndex):

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

Source/WebCore/ChangeLog
Source/WebCore/html/HTMLTextFormControlElement.cpp

index 1dba6723c4953571fb100999efc051beb09bc093..f2a6a7377dab159b98a53fa89b8419f813c75ed9 100644 (file)
@@ -1,3 +1,11 @@
+2014-02-10  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Address the review comments for r163825.
+
+        * html/HTMLTextFormControlElement.cpp:
+        (WebCore::HTMLTextFormControlElement::indexForVisiblePosition):
+        (WebCore::positionForIndex):
+
 2014-02-10  Simon Fraser  <simon.fraser@apple.com>
 
         Try to fix the 32-bit build.
index 1c29a646e982ac286fe9efc92776d7ff3a86e7a3..3eae47ae8068eb1adc56134b0a19398407d9eef7 100644 (file)
@@ -321,14 +321,14 @@ void HTMLTextFormControlElement::setSelectionRange(int start, int end, TextField
         frame->selection().setSelection(newSelection);
 }
 
-int HTMLTextFormControlElement::indexForVisiblePosition(const VisiblePosition& pos) const
+int HTMLTextFormControlElement::indexForVisiblePosition(const VisiblePosition& position) const
 {
     TextControlInnerTextElement* innerText = innerTextElement();
-    if (!innerText || !innerText->contains(pos.deepEquivalent().anchorNode()))
+    if (!innerText || !innerText->contains(position.deepEquivalent().anchorNode()))
         return 0;
     bool forSelectionPreservation = false;
-    unsigned index = WebCore::indexForVisiblePosition(innerTextElement(), pos, forSelectionPreservation);
-    ASSERT(VisiblePosition(positionForIndex(innerTextElement(), index)) == pos);
+    unsigned index = WebCore::indexForVisiblePosition(innerTextElement(), position, forSelectionPreservation);
+    ASSERT(VisiblePosition(positionForIndex(innerTextElement(), index)) == position);
     return index;
 }
 
@@ -566,10 +566,10 @@ static Position positionForIndex(TextControlInnerTextElement* innerText, unsigne
                 return positionBeforeNode(node);
             remainingCharactersToMoveForward--;
         } else if (node->isTextNode()) {
-            Text* text = toText(node);
-            if (remainingCharactersToMoveForward < text->length())
-                return Position(text, remainingCharactersToMoveForward);
-            remainingCharactersToMoveForward -= text->length();
+            Text& text = toText(*node);
+            if (remainingCharactersToMoveForward < text.length())
+                return Position(&text, remainingCharactersToMoveForward);
+            remainingCharactersToMoveForward -= text.length();
         }
     }
     return lastPositionInNode(innerText);