WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 128806
computeSelectionStart and computeSelectionEnd shouldn't trigger synchronous layout
https://bugs.webkit.org/show_bug.cgi?id=128806
Summary
computeSelectionStart and computeSelectionEnd shouldn't trigger synchronous l...
Ryosuke Niwa
Reported
2014-02-14 02:28:53 PST
This is similar to the
bug 128478
. computeSelectionStart() and computeSelectionStart() in HTMLTextFormControlElement use indexForVisiblePosition to compute start and end indexes 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 traverse through the shadow DOM with regular Position instead of VisiblePosition.
Attachments
Fixes the bug
(6.11 KB, patch)
2014-02-15 03:31 PST
,
Ryosuke Niwa
darin
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Ryosuke Niwa
Comment 1
2014-02-15 03:31:04 PST
Created
attachment 224295
[details]
Fixes the bug
Darin Adler
Comment 2
2014-02-15 09:37:50 PST
Comment on
attachment 224295
[details]
Fixes the bug View in context:
https://bugs.webkit.org/attachment.cgi?id=224295&action=review
> Source/WebCore/html/HTMLTextFormControlElement.cpp:333 > + int index = indexForPosition(position.deepEquivalent());
Why int rather than unsigned?
> Source/WebCore/html/HTMLTextFormControlElement.cpp:601 > + index += std::min(length, static_cast<unsigned>(passedPosition.offsetInContainerNode()));
Instead of static_cast<unsigned>, I suggest writing std::min<unsigned>.
> Source/WebCore/html/HTMLTextFormControlElement.cpp:616 > +#ifndef NDEBUG > + VisiblePosition visiblePosition = passedPosition; > + unsigned indexComputedByVisiblePosition = 0; > + if (visiblePosition.isNotNull()) > + indexComputedByVisiblePosition = WebCore::indexForVisiblePosition(innerText, visiblePosition, false /* forSelectionPreservation */); > + ASSERT(index == indexComputedByVisiblePosition); > +#endif
I think an assertion like this should be written with a helper function so it doesn’t need to be inside an #if. Also can consider ASSERT_DISABLED instead of NDEBUG.
Ryosuke Niwa
Comment 3
2014-02-15 11:56:28 PST
(In reply to
comment #2
)
> (From update of
attachment 224295
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=224295&action=review
> > > Source/WebCore/html/HTMLTextFormControlElement.cpp:333 > > + int index = indexForPosition(position.deepEquivalent()); > > Why int rather than unsigned?
Will fix.
> > Source/WebCore/html/HTMLTextFormControlElement.cpp:601 > > + index += std::min(length, static_cast<unsigned>(passedPosition.offsetInContainerNode())); > > Instead of static_cast<unsigned>, I suggest writing std::min<unsigned>.
Will fix.
> > Source/WebCore/html/HTMLTextFormControlElement.cpp:616 > > +#ifndef NDEBUG > > + VisiblePosition visiblePosition = passedPosition; > > + unsigned indexComputedByVisiblePosition = 0; > > + if (visiblePosition.isNotNull()) > > + indexComputedByVisiblePosition = WebCore::indexForVisiblePosition(innerText, visiblePosition, false /* forSelectionPreservation */); > > + ASSERT(index == indexComputedByVisiblePosition); > > +#endif > > I think an assertion like this should be written with a helper function so it doesn’t need to be inside an #if. Also can consider ASSERT_DISABLED instead of NDEBUG.
I'd like to be able to see indexComputedByVisiblePosition and visiblePosition for debugging purposes when the assertion is hit. If I put the computation inside a helper function, it would be tricky to get those objects/values in the debugger. But I'd use ASSERT_DISABLED.
Ryosuke Niwa
Comment 4
2014-02-15 15:19:57 PST
Committed
r164180
: <
http://trac.webkit.org/changeset/164180
>
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