WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED WONTFIX
48151
Add a new version of setSelection that fires selectionchange event
https://bugs.webkit.org/show_bug.cgi?id=48151
Summary
Add a new version of setSelection that fires selectionchange event
Ryosuke Niwa
Reported
2010-10-22 13:29:46 PDT
Add a wrapper for setSelection that also fires selectionchange event. We intend to migrate most of calls to setSelection to this new version.
Attachments
Patch
(30.58 KB, patch)
2010-10-25 12:56 PDT
,
Ryosuke Niwa
no flags
Details
Formatted Diff
Diff
implements setSelectionFiringEvent with a test
(39.27 KB, patch)
2010-11-05 19:16 PDT
,
Ryosuke Niwa
no flags
Details
Formatted Diff
Diff
fixed per comments
(74.43 KB, patch)
2010-11-08 15:35 PST
,
Ryosuke Niwa
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Alexey Proskuryakov
Comment 1
2010-10-22 16:51:59 PDT
The feature probably needs to be under an ifdef during development, so that no one accidentally ships selectionchange that _sometimes_ works.
Ryosuke Niwa
Comment 2
2010-10-22 16:56:12 PDT
(In reply to
comment #1
)
> The feature probably needs to be under an ifdef during development, so that no one accidentally ships selectionchange that _sometimes_ works.
Yes, that is the plan. I'm currently working on that. I have wrapped all the code I've added so far by ENABLE(SELECTIONCHANGE_EVENT) but I can't figure out how to enable it locally. Is there a command-line option to build-webkit? Or do I define the constant in XCode?
Alexey Proskuryakov
Comment 3
2010-10-22 17:07:09 PDT
The default is in WebCore/Configurations/FeatureDefines.xcconfig. Command line options can be added to build-webkit script.
Ryosuke Niwa
Comment 4
2010-10-25 12:56:18 PDT
Created
attachment 71785
[details]
Patch
Ryosuke Niwa
Comment 5
2010-11-05 19:16:08 PDT
Created
attachment 73159
[details]
implements setSelectionFiringEvent with a test
Alexey Proskuryakov
Comment 6
2010-11-08 11:49:16 PST
Comment on
attachment 73159
[details]
implements setSelectionFiringEvent with a test +void SelectionController::setSelectionFiringEvent(const VisibleSelection& s, bool closeTyping, bool shouldClearTypingStyle, bool userTriggered, CursorAlignOnScroll align, TextGranularity granularity, DirectionalityPolicy directionalityPolicy) I've been reading this as "set SelectionFiring event" until I saw the implementation. Maybe setSelectionWithEvent()? Or combine the options into a structure, and add that to it? +#if ENABLE(SELECTIONCHANGE_EVENT) + m_frame->document()->dispatchEvent(Event::create(eventNames().selectionchangeEvent, false, false)); +#endif Can m_frame be null? SelectionController::setSelection() has a null check for it. - m_frame->selection()->setSelection(newSelection, granularity, MakeNonDirectionalSelection); + m_frame->selection()->setSelectionFiringEvent(newSelection, granularity, MakeNonDirectionalSelection); I don't know how to review such changes for security impact. +FAIL: double clicking first word of "<a href="javascript:false">hello</a>" yielded 0 selectionchange events but expected 2 events The test is not enabled on any platforms, why check in a FAIL result? That should be a at least explained in ChangeLog.
Darin Adler
Comment 7
2010-11-08 11:56:54 PST
Comment on
attachment 73159
[details]
implements setSelectionFiringEvent with a test The naming here is not great. The normal version of the function is the one that sends events. The current version of the function which does not send events is the “buggy” one. I think first step here should be renaming the current one to include the word “deprecated” or “without sending events” or both. We don’t want to leave a rename as the last step if we can help it.
Ryosuke Niwa
Comment 8
2010-11-08 15:34:00 PST
(In reply to
comment #6
)
> (From update of
attachment 73159
[details]
) > I've been reading this as "set SelectionFiring event" until I saw the implementation. Maybe setSelectionWithEvent()? Or combine the options into a structure, and add that to it?
Oh yeah, that's a good point now that you pointed out. I can't step reading it that way. Will fix.
> +#if ENABLE(SELECTIONCHANGE_EVENT) > + m_frame->document()->dispatchEvent(Event::create(eventNames().selectionchangeEvent, false, false)); > +#endif > > Can m_frame be null? SelectionController::setSelection() has a null check for it.
Will fix.
> - m_frame->selection()->setSelection(newSelection, granularity, MakeNonDirectionalSelection); > + m_frame->selection()->setSelectionFiringEvent(newSelection, granularity, MakeNonDirectionalSelection); > > I don't know how to review such changes for security impact.
I added a comment to each test case indicating which case corresponds to which. The only function I haven't been able to test is selectClosestWordOrLinkFromMouseEvent. I ran all layout tests with ASSERT_NOT_REACHED but it never hit the assert. It's quite possible that it's dead code.
> +FAIL: double clicking first word of "<a href="javascript:false">hello</a>" yielded 0 selectionchange events but expected 2 events > > The test is not enabled on any platforms, why check in a FAIL result? That should be a at least explained in ChangeLog.
I'll just remove this test. (In reply to
comment #7
)
> (From update of
attachment 73159
[details]
) > The naming here is not great. The normal version of the function is the one that sends events. The current version of the function which does not send events is the “buggy” one. I think first step here should be renaming the current one to include the word “deprecated” or “without sending events” or both.
Will rename setSelection to deprecatedSetSelection. I'd like to keep the name setSelectionWithEvent for this very first patch. Because if I had used setSelection in this patch, reviewers need to go through every single file to make sure I caught them all. Calling it setSelectionWithEvent will avoid this because it'll show up as a compilation error if I had forgotten any.
Ryosuke Niwa
Comment 9
2010-11-08 15:35:11 PST
Created
attachment 73295
[details]
fixed per comments
Eric Seidel (no email)
Comment 10
2010-11-08 17:04:59 PST
Attachment 73295
[details]
did not build on chromium: Build output:
http://queues.webkit.org/results/5431038
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