WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
57088
Refactoring: Editor::TextCheckingOptions should be replaced with TextCheckingType
https://bugs.webkit.org/show_bug.cgi?id=57088
Summary
Refactoring: Editor::TextCheckingOptions should be replaced with TextChecking...
Hajime Morrita
Reported
2011-03-25 00:18:29 PDT
These two are almost identical. We should use one of them. And the enum is actually a bitmask. So TextCheckingType should be a class, which has bitfields for each flag. Marked blocked by 2 refactoring bugs, which touch the spellchecking area.
Attachments
Patch
(70.21 KB, patch)
2011-04-06 19:49 PDT
,
Hajime Morrita
no flags
Details
Formatted Diff
Diff
Patch
(70.21 KB, patch)
2011-04-06 20:19 PDT
,
Hajime Morrita
no flags
Details
Formatted Diff
Diff
Patch
(70.42 KB, patch)
2011-04-07 11:22 PDT
,
Hajime Morrita
no flags
Details
Formatted Diff
Diff
Updated to ToT
(70.11 KB, patch)
2011-04-11 12:15 PDT
,
Hajime Morrita
no flags
Details
Formatted Diff
Diff
Updated to ToT
(70.30 KB, patch)
2011-04-15 16:18 PDT
,
Hajime Morrita
no flags
Details
Formatted Diff
Diff
A build fix
(71.38 KB, patch)
2011-04-19 09:08 PDT
,
Hajime Morrita
no flags
Details
Formatted Diff
Diff
Patch
(71.35 KB, patch)
2011-04-19 17:48 PDT
,
Hajime Morrita
no flags
Details
Formatted Diff
Diff
Patch
(70.10 KB, patch)
2011-05-12 01:21 PDT
,
Hajime Morrita
no flags
Details
Formatted Diff
Diff
Patch
(11.05 KB, patch)
2011-05-13 05:22 PDT
,
Hajime Morrita
rniwa
: review+
Details
Formatted Diff
Diff
Show Obsolete
(8)
View All
Add attachment
proposed patch, testcase, etc.
Hajime Morrita
Comment 1
2011-04-06 19:49:04 PDT
Created
attachment 88559
[details]
Patch
WebKit Review Bot
Comment 2
2011-04-06 20:09:57 PDT
Attachment 88559
[details]
did not build on chromium: Build output:
http://queues.webkit.org/results/8346447
Hajime Morrita
Comment 3
2011-04-06 20:19:12 PDT
Created
attachment 88562
[details]
Patch
WebKit Review Bot
Comment 4
2011-04-06 20:47:04 PDT
Attachment 88562
[details]
did not build on chromium: Build output:
http://queues.webkit.org/results/8348427
Ryosuke Niwa
Comment 5
2011-04-07 03:51:28 PDT
Comment on
attachment 88562
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=88562&action=review
> Source/WebCore/editing/Editor.cpp:2226 > + bool shouldMarkSpelling = textCheckingTypes.spelling(); > + bool shouldMarkGrammar = textCheckingTypes.grammar(); > + bool shouldPerformReplacement = textCheckingTypes.replacement(); > + bool shouldShowCorrectionPanel = textCheckingTypes.correctionPanel(); > + bool shouldCheckForCorrection = shouldShowCorrectionPanel || textCheckingTypes.correction();
I think these member functions should be named as isSpelling, isGrammar, etc...
> Source/WebCore/editing/Editor.cpp:3623 > -TextCheckingTypeMask Editor::textCheckingTypeMaskFor(TextCheckingOptions textCheckingOptions) > +TextCheckingTypes Editor::addTextCheckSettings(const TextCheckingTypes& textCheckingTypes)
I don't think this function name makes sense since you're not modifying the original textCheckingTypes. Something like resolveReplacedTextCheckingType might work.
WebKit Review Bot
Comment 6
2011-04-07 06:38:02 PDT
Attachment 88562
[details]
did not build on chromium: Build output:
http://queues.webkit.org/results/8341639
Hajime Morrita
Comment 7
2011-04-07 11:22:19 PDT
Created
attachment 88665
[details]
Patch
Hajime Morrita
Comment 8
2011-04-07 11:23:05 PDT
Hi Ryosuke, thank you for taking a look! I update the patch to your feedback. (In reply to
comment #5
)
> (From update of
attachment 88562
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=88562&action=review
> > > Source/WebCore/editing/Editor.cpp:2226 > > + bool shouldMarkSpelling = textCheckingTypes.spelling(); > > + bool shouldMarkGrammar = textCheckingTypes.grammar(); > > + bool shouldPerformReplacement = textCheckingTypes.replacement(); > > + bool shouldShowCorrectionPanel = textCheckingTypes.correctionPanel(); > > + bool shouldCheckForCorrection = shouldShowCorrectionPanel || textCheckingTypes.correction(); > > I think these member functions should be named as isSpelling, isGrammar, etc...
Fixed.
> > > Source/WebCore/editing/Editor.cpp:3623 > > -TextCheckingTypeMask Editor::textCheckingTypeMaskFor(TextCheckingOptions textCheckingOptions) > > +TextCheckingTypes Editor::addTextCheckSettings(const TextCheckingTypes& textCheckingTypes) > > I don't think this function name makes sense since you're not modifying the original textCheckingTypes. Something like resolveReplacedTextCheckingType might work.
Fixed.
Hajime Morrita
Comment 9
2011-04-11 12:15:42 PDT
Created
attachment 89049
[details]
Updated to ToT
Hajime Morrita
Comment 10
2011-04-15 16:18:45 PDT
Created
attachment 89871
[details]
Updated to ToT
WebKit Review Bot
Comment 11
2011-04-15 20:07:41 PDT
Attachment 89871
[details]
did not build on mac: Build output:
http://queues.webkit.org/results/8457309
Daniel Bates
Comment 12
2011-04-15 21:10:16 PDT
Attachment 89871
[details]
did not build on mac: Build output:
http://queues.webkit.org/results/8436375
Hajime Morrita
Comment 13
2011-04-19 09:08:17 PDT
Created
attachment 90210
[details]
A build fix
Hajime Morrita
Comment 14
2011-04-19 13:01:43 PDT
Build passed. It's ready to review!
Jia Pu
Comment 15
2011-04-19 15:44:11 PDT
Comment on
attachment 90210
[details]
A build fix View in context:
https://bugs.webkit.org/attachment.cgi?id=90210&action=review
> Source/WebCore/editing/Editor.cpp:3249 > - bool shouldMarkSpelling = textCheckingOptions & MarkSpelling; > - bool shouldMarkGrammar = textCheckingOptions & MarkGrammar; > - bool shouldShowCorrectionPanel = textCheckingOptions & ShowCorrectionPanel; > - bool shouldCheckForCorrection = shouldShowCorrectionPanel || (textCheckingOptions & CheckForCorrection); > - > - TextCheckingTypeMask checkingTypes = 0; > - if (shouldMarkSpelling) > - checkingTypes |= TextCheckingTypeSpelling; > - if (shouldMarkGrammar) > - checkingTypes |= TextCheckingTypeGrammar; > - if (shouldCheckForCorrection) > - checkingTypes |= TextCheckingTypeCorrection; > - > + TextCheckingTypes result = types;
This change is problematic at least on Mac. In original code, TextCheckingTypeCorrection will be set if ShowCorrectionPanel is set in textCheckingOptions. This is not the case in new code. The end result is that, if types.isCorrectionPanel() is true, but types.isCorrection() is false, the spell checker will not check for correction. I suggest to add code here to call setCorrection() if types.isCorrectionPanel() is true.
Hajime Morrita
Comment 16
2011-04-19 17:48:50 PDT
Created
attachment 90281
[details]
Patch
Hajime Morrita
Comment 17
2011-04-19 17:50:52 PDT
Hi Jia, thank you for your feedback! I updated to patch to address your point. I confused the relationship between checking and showing the correction. (In reply to
comment #15
)
> (From update of
attachment 90210
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=90210&action=review
> > > Source/WebCore/editing/Editor.cpp:3249 > > - bool shouldMarkSpelling = textCheckingOptions & MarkSpelling; > > - bool shouldMarkGrammar = textCheckingOptions & MarkGrammar; > > - bool shouldShowCorrectionPanel = textCheckingOptions & ShowCorrectionPanel; > > - bool shouldCheckForCorrection = shouldShowCorrectionPanel || (textCheckingOptions & CheckForCorrection); > > - > > - TextCheckingTypeMask checkingTypes = 0; > > - if (shouldMarkSpelling) > > - checkingTypes |= TextCheckingTypeSpelling; > > - if (shouldMarkGrammar) > > - checkingTypes |= TextCheckingTypeGrammar; > > - if (shouldCheckForCorrection) > > - checkingTypes |= TextCheckingTypeCorrection; > > - > > + TextCheckingTypes result = types; > > This change is problematic at least on Mac. In original code, TextCheckingTypeCorrection will be set if ShowCorrectionPanel is set in textCheckingOptions. This is not the case in new code. The end result is that, if types.isCorrectionPanel() is true, but types.isCorrection() is false, the spell checker will not check for correction. I suggest to add code here to call setCorrection() if types.isCorrectionPanel() is true.
Jia Pu
Comment 18
2011-04-20 12:17:07 PDT
(In reply to
comment #16
)
> Created an attachment (id=90281) [details] > Patch
Thanks for fixing this. This patch looks good to me.
Ryosuke Niwa
Comment 19
2011-05-03 09:35:59 PDT
Comment on
attachment 90281
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=90281&action=review
> Source/WebCore/editing/Editor.cpp:1981 > + && (isAutomaticQuoteSubstitutionEnabled()
I don't think we do these deep indentation. Ditto about other places.
> Source/WebCore/editing/Editor.cpp:3259 > + if (types.isReplacement()) { > + result.setLink(isAutomaticLinkDetectionEnabled()); > + result.setQuote(isAutomaticQuoteSubstitutionEnabled()); > + result.setDash(isAutomaticDashSubstitutionEnabled()); > + result.setReplacement(isAutomaticTextReplacementEnabled()); > + result.setCorrection(types.isSpelling() && isAutomaticSpellingCorrectionEnabled()); > }
It seems silly that we have to copy flags manually like this. Can't we make this function a member of TextCheckingTypes and use bitwise operations? Also, it's hard to verify that adding Correction to TypeCheckingTypes doesn't regress anything. Could you explain briefly why it's okay?
> Source/WebCore/platform/text/TextChecking.h:54 > + Correction = 1 << 9,
This is a new value. I can't tell easily from the patch whether this is correct or not.
> Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm:860 > +static unsigned toNSTypes(const TextCheckingTypes& types)
Don't they normally name these kinds of functions kit?
> Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:241 > +static unsigned toNSTypes(const TextCheckingTypes& types)
Ditto.
Hajime Morrita
Comment 20
2011-05-12 01:21:46 PDT
Created
attachment 93265
[details]
Patch
Hajime Morrita
Comment 21
2011-05-12 01:22:38 PDT
Comment on
attachment 90281
[details]
Patch Hi Ryosuke, I'm sorry for my slow response. I'd like to come back this now. View in context:
https://bugs.webkit.org/attachment.cgi?id=90281&action=review
>> Source/WebCore/editing/Editor.cpp:1981 >> + && (isAutomaticQuoteSubstitutionEnabled() > > I don't think we do these deep indentation. Ditto about other places.
Fixed.
>> Source/WebCore/editing/Editor.cpp:3259 >> } > > It seems silly that we have to copy flags manually like this. Can't we make this function a member of TextCheckingTypes and use bitwise operations? Also, it's hard to verify that adding Correction to TypeCheckingTypes doesn't regress anything. Could you explain briefly why it's okay?
No, we cannot. because flags source is Editor class (or Settings class) and there is no grouping mechanism for these flag on settings side. Actually this code is what old code was doing.
>> Source/WebCore/platform/text/TextChecking.h:54 >> + Correction = 1 << 9, > > This is a new value. I can't tell easily from the patch whether this is correct or not.
Actually, what new is "TextCheckingTypes::CorrectionPanel" "TextCheckingTypes::Correction" has associated old enum value TextCheckingTypeCorrection. The value TextCheckingTypes::Correction panel came from Editor:: ShowCorrectionPanel. The goal of this patch is unifying TextCheckingType, which is for carring result type, and Editor::TextCheckingOptionFlags, which is for specifying request type, into TextCheckingTypes. because the results basically contain what the caller requested. So code paths where originally TextCheckingType don't need to care about CorrectionPanel. The code where originally used Editor:: ShowCorrectionPanel should replace them with TextCheckingTypes::CorrectionPanel.
> Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm:861 > +{
That's right. Renamed.
> Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:242 > +{
Done
Darin Adler
Comment 22
2011-05-12 09:56:25 PDT
Comment on
attachment 93265
[details]
Patch Is there any way to do this in more smaller steps?
Hajime Morrita
Comment 23
2011-05-12 19:53:28 PDT
(In reply to
comment #22
)
> (From update of
attachment 93265
[details]
) > Is there any way to do this in more smaller steps?
I see. I'll try to use plain enum instead of a new class, and concentrate to eliminate Editor::TextCheckingOptions at first. Thanks for your feedback!
Hajime Morrita
Comment 24
2011-05-13 05:22:20 PDT
Created
attachment 93437
[details]
Patch
Hajime Morrita
Comment 25
2011-05-13 05:23:34 PDT
Darin is right. Now the change becomes small and obvious.
Ryosuke Niwa
Comment 26
2011-05-13 09:47:54 PDT
Comment on
attachment 93437
[details]
Patch LGTM. this patch is so much easier to review!
Hajime Morrita
Comment 27
2011-05-15 19:46:31 PDT
Committed
r86520
: <
http://trac.webkit.org/changeset/86520
>
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