setSelectionRange uses visiblePositionForIndex to obtain start and end positions but we shouldn't need to since we only have br elements and text nodes inside the shadow DOM of inputs and text area elements. We should be able to obtain a regular Position by traversing through the DOM, which is significantly more efficient than creating a VisiblePosition
Created attachment 223594 [details] Cleanup
Comment on attachment 223594 [details] Cleanup View in context: https://bugs.webkit.org/attachment.cgi?id=223594&action=review > Source/WebCore/html/HTMLTextFormControlElement.cpp:55 > +static Position positionForIndex(TextControlInnerTextElement*, unsigned); I suggest taking a reference here rather than a pointer. > Source/WebCore/html/HTMLTextFormControlElement.cpp:324 > int HTMLTextFormControlElement::indexForVisiblePosition(const VisiblePosition& pos) const Why not rename pos to position while you are changing this entire function? > Source/WebCore/html/HTMLTextFormControlElement.cpp:569 > + Text* text = toText(node); This should be: Text& text = toText(*node); Because we know node is non-null.
Committed r163825: <http://trac.webkit.org/changeset/163825>
Oops, I somehow missed these review comments. Fixed them in http://trac.webkit.org/changeset/163846 (In reply to comment #2) > (From update of attachment 223594 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=223594&action=review > > > Source/WebCore/html/HTMLTextFormControlElement.cpp:55 > > +static Position positionForIndex(TextControlInnerTextElement*, unsigned); > > I suggest taking a reference here rather than a pointer. Unfortunately the pointer could be null in all 3 call sites :( > > Source/WebCore/html/HTMLTextFormControlElement.cpp:324 > > int HTMLTextFormControlElement::indexForVisiblePosition(const VisiblePosition& pos) const > > Why not rename pos to position while you are changing this entire function? Done. > > Source/WebCore/html/HTMLTextFormControlElement.cpp:569 > > + Text* text = toText(node); > > This should be: > > Text& text = toText(*node); > > Because we know node is non-null. Done.