Bug 56324 - EventHandler calls shouldChangeSelection needlessly
Summary: EventHandler calls shouldChangeSelection needlessly
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Enhancement
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-14 12:46 PDT by Ryosuke Niwa
Modified: 2011-03-14 19:07 PDT (History)
2 users (show)

See Also:


Attachments
fixes the bug (30.89 KB, patch)
2011-03-14 17:37 PDT, Ryosuke Niwa
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2011-03-14 12:46:45 PDT
Currently, EventHandler::updateSelectionForMouseDrag calls shouldChangeSelection regardless of whether current selection is different from new selection or not.  We should not call shouldChangeSelection when no change is needed.
Comment 1 Ryosuke Niwa 2011-03-14 17:37:52 PDT
Created attachment 85746 [details]
fixes the bug
Comment 2 Darin Adler 2011-03-14 17:51:44 PDT
Comment on attachment 85746 [details]
fixes the bug

View in context: https://bugs.webkit.org/attachment.cgi?id=85746&action=review

> Source/WebCore/page/EventHandler.cpp:662
> -    if (m_frame->selection()->shouldChangeSelection(newSelection)) {
> -        m_frame->selection()->setIsDirectional(false);
> -        m_frame->selection()->setSelection(newSelection, m_frame->selection()->granularity(), MakeNonDirectionalSelection);
> -    }
> +    setNonDirectionalSelectionIfNeeded(m_frame->selection(), newSelection, m_frame->selection()->granularity());

What does the setIsDirectional(false) work in the new code?
Comment 3 Ryosuke Niwa 2011-03-14 17:54:02 PDT
(In reply to comment #2)
> (From update of attachment 85746 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=85746&action=review
> 
> > Source/WebCore/page/EventHandler.cpp:662
> > -    if (m_frame->selection()->shouldChangeSelection(newSelection)) {
> > -        m_frame->selection()->setIsDirectional(false);
> > -        m_frame->selection()->setSelection(newSelection, m_frame->selection()->granularity(), MakeNonDirectionalSelection);
> > -    }
> > +    setNonDirectionalSelectionIfNeeded(m_frame->selection(), newSelection, m_frame->selection()->granularity());
> 
> What does the setIsDirectional(false) work in the new code?

The first thing SelectionController::setSelection does is to call setIsDirectional(directionalityPolicy == MakeDirectionalSelection) so call to setIsDirectional here was completely redundant.
Comment 4 Ryosuke Niwa 2011-03-14 17:56:33 PDT
Having said that, there's a behavioral change that after this patch WebKit won't change previously directional selection to non-directional in EventHandler but that's rarely an issue because I don't think users nor scripts can make such changes.
Comment 5 Ryosuke Niwa 2011-03-14 17:57:25 PDT
(In reply to comment #4)
>that's rarely
should read "that shouldn't be"
Comment 6 Ryosuke Niwa 2011-03-14 19:07:26 PDT
Committed r81095: <http://trac.webkit.org/changeset/81095>