WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
128478
HTMLTextFormControlElement::setSelectionRange shouldn't use VisiblePosition
https://bugs.webkit.org/show_bug.cgi?id=128478
Summary
HTMLTextFormControlElement::setSelectionRange shouldn't use VisiblePosition
Ryosuke Niwa
Reported
2014-02-08 15:35:50 PST
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
Attachments
Cleanup
(5.92 KB, patch)
2014-02-08 16:25 PST
,
Ryosuke Niwa
darin
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Ryosuke Niwa
Comment 1
2014-02-08 16:25:19 PST
Created
attachment 223594
[details]
Cleanup
Darin Adler
Comment 2
2014-02-09 23:41:45 PST
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.
Ryosuke Niwa
Comment 3
2014-02-10 15:00:15 PST
Committed
r163825
: <
http://trac.webkit.org/changeset/163825
>
Ryosuke Niwa
Comment 4
2014-02-11 00:53:17 PST
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.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug