WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
161894
Undoing a candidate insertion results in the replaced text being selected
https://bugs.webkit.org/show_bug.cgi?id=161894
Summary
Undoing a candidate insertion results in the replaced text being selected
Tim Horton
Reported
2016-09-12 23:44:56 PDT
Undoing a candidate insertion results in the replaced text being selected
Attachments
Patch
(36.27 KB, patch)
2016-09-12 23:45 PDT
,
Tim Horton
no flags
Details
Formatted Diff
Diff
Patch
(37.43 KB, patch)
2016-09-12 23:48 PDT
,
Tim Horton
simon.fraser
: review+
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Tim Horton
Comment 1
2016-09-12 23:45:27 PDT
Created
attachment 288677
[details]
Patch
Tim Horton
Comment 2
2016-09-12 23:45:55 PDT
rdar://problem/28225774
Tim Horton
Comment 3
2016-09-12 23:48:47 PDT
Created
attachment 288678
[details]
Patch
Wenson Hsieh
Comment 4
2016-09-13 07:34:12 PDT
Comment on
attachment 288678
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=288678&action=review
> Source/WebCore/ChangeLog:24 > + Make use of the new editor command to do candidate insertion as a single
Awesome! Will this also take care of the single EditorState update with selectionIsRange = true as well when inserting a candidate?
> Source/WebCore/editing/Editor.cpp:3641 > + Ref<ReplaceRangeWithTextCommand> replaceCommand = ReplaceRangeWithTextCommand::create(range.get(), acceptedCandidate.replacement);
Can we use auto here?
Simon Fraser (smfr)
Comment 5
2016-09-13 08:42:17 PDT
Comment on
attachment 288678
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=288678&action=review
> Source/WebCore/editing/Editor.cpp:3621 > +RefPtr<Range> Editor::rangeForTextCheckingResult(const TextCheckingResult& result) const
I can't parse this. Is it "range for text-checking-result", or "range for text, checking result"?
> Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp:41 > +ReplaceRangeWithTextCommand::ReplaceRangeWithTextCommand(PassRefPtr<Range> rangeToBeReplaced, const String& text)
Do we have to still PassRefPtr<>?
> Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp:52 > + String previousText = plainText(m_rangeToBeReplaced.get()); > + if (!previousText.length()) > + return;
Why go to the cost of getting the previous text (which may be megabytes) rather than just asking the range if it's empty?
> Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp:57 > + if (!frame().selection().shouldChangeSelection(selection)) > + return;
Would have been cheaper to do this first.
> Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp:60 > + if (!m_rangeToBeReplaced) > + return;
And this.
> Source/WebCore/editing/ReplaceRangeWithTextCommand.h:27 > +#ifndef ReplaceRangeWithTextCommand_h > +#define ReplaceRangeWithTextCommand_h
The cool kids are using #pragma once now.
Tim Horton
Comment 6
2016-09-13 09:55:04 PDT
(In reply to
comment #5
)
> Comment on
attachment 288678
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=288678&action=review
> > > Source/WebCore/editing/Editor.cpp:3621 > > +RefPtr<Range> Editor::rangeForTextCheckingResult(const TextCheckingResult& result) const > > I can't parse this. Is it "range for text-checking-result", or "range for > text, checking result"?
The only argument is a TextCheckingResult :)
> > Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp:41 > > +ReplaceRangeWithTextCommand::ReplaceRangeWithTextCommand(PassRefPtr<Range> rangeToBeReplaced, const String& text) > > Do we have to still PassRefPtr<>?
No. I'll fix that.
> > Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp:52 > > + String previousText = plainText(m_rangeToBeReplaced.get()); > > + if (!previousText.length()) > > + return; > > Why go to the cost of getting the previous text (which may be megabytes) > rather than just asking the range if it's empty?
I don't know (I'm just mimicing spell checking code), but I do know that plainText().length() and the range length are two very different things.
> > Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp:57 > > + if (!frame().selection().shouldChangeSelection(selection)) > > + return; > > Would have been cheaper to do this first. > > > Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp:60 > > + if (!m_rangeToBeReplaced) > > + return; > > And this. > > > Source/WebCore/editing/ReplaceRangeWithTextCommand.h:27 > > +#ifndef ReplaceRangeWithTextCommand_h > > +#define ReplaceRangeWithTextCommand_h > > The cool kids are using #pragma once now.
Sure.
Tim Horton
Comment 7
2016-09-13 12:47:04 PDT
https://trac.webkit.org/changeset/205870
Darin Adler
Comment 8
2016-09-14 09:57:35 PDT
Comment on
attachment 288678
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=288678&action=review
>>> Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp:52 >>> + return; >> >> Why go to the cost of getting the previous text (which may be megabytes) rather than just asking the range if it's empty? > > I don't know (I'm just mimicing spell checking code), but I do know that plainText().length() and the range length are two very different things.
There is no doubt that we can write a function that returns a boolean indicating whether plainText would be empty that is far more efficient than actually calling plainText and then length. But literally checking if the range is “empty” would not be the algorithm for that function.
Darin Adler
Comment 9
2016-09-14 12:35:48 PDT
Comment on
attachment 288678
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=288678&action=review
> Source/WebCore/editing/Editor.cpp:3642 > + Ref<ReplaceRangeWithTextCommand> replaceCommand = ReplaceRangeWithTextCommand::create(range.get(), acceptedCandidate.replacement); > + applyCommand(replaceCommand.ptr());
This kind of thing reads better without the local variable: applyCommand(ReplaceRangeWithTextCommand::create(range.get(), acceptedCandidate.replacement).ptr());
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