Bug 174594 - Cleanup: Use OptionSet to represent marker types
Summary: Cleanup: Use OptionSet to represent marker types
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Local Build
Hardware: All All
: P2 Normal
Assignee: Daniel Bates
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-17 14:23 PDT by Daniel Bates
Modified: 2017-07-17 20:27 PDT (History)
3 users (show)

See Also:


Attachments
Patch (35.01 KB, patch)
2017-07-17 14:25 PDT, Daniel Bates
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bates 2017-07-17 14:23:13 PDT
Class DocumentMarker::MarkerTypes represents bitmask of marker types and duplicates most of the functionality of OptionSet. Unlike OptionSet, DocumentMarker::MarkerTypes does not support iteration and hence code, such as AlternativeTextController::applyAlternativeTextToRange(), uses Vector<DocumentMarker::MarkerType> to represent a set of marker types. We can use OptionSet to support both uses cases in a space- and time- efficient manner.
Comment 1 Daniel Bates 2017-07-17 14:25:46 PDT
Created attachment 315713 [details]
Patch
Comment 2 Darin Adler 2017-07-17 18:50:50 PDT
Comment on attachment 315713 [details]
Patch

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

> Source/WebCore/dom/DocumentMarker.h:164
> +        AcceptedCandidate
> +        , Autocorrected
> +        , CorrectionIndicator
> +        , DeletedAutocorrection
> +        , DictationAlternatives
> +        , Grammar
> +        , RejectedCorrection
> +        , Replacement
> +        , SpellCheckingExemption
> +        , Spelling
> +        , TextMatch
> +#if ENABLE(TELEPHONE_NUMBER_DETECTION)
> +        , TelephoneNumber
> +#endif
> +#if PLATFORM(IOS)
> +        , DictationPhraseWithAlternatives
> +        , DictationResult
> +#endif
> +        , DraggedContent

I would like to see this sorted alphabetically (including "DraggedContent", but not including the conditional items. And we should use trailing commas instead of leading commas, with the extra one at the end that C++ allows in initializer lists. That way we don’t have to have one line different from the others.

> Source/WebCore/editing/Editor.cpp:2752
> +        DocumentMarker::Spelling, DocumentMarker::CorrectionIndicator, DocumentMarker::SpellCheckingExemption,
> +        DocumentMarker::DictationAlternatives
> +#if !PLATFORM(IOS)
> +        , DocumentMarker::Grammar
>  #endif

Trailing commas after each item is a cleaner way to do this since you can have an extra comma.
Comment 3 Darin Adler 2017-07-17 18:54:00 PDT
You will have to rebase and merge with r219595 since it overlaps some functions you changed.
Comment 4 Daniel Bates 2017-07-17 19:35:14 PDT
(In reply to Darin Adler from comment #2)
> > Source/WebCore/dom/DocumentMarker.h:164
> > +        AcceptedCandidate
> > +        , Autocorrected
> > +        , CorrectionIndicator
> > +        , DeletedAutocorrection
> > +        , DictationAlternatives
> > +        , Grammar
> > +        , RejectedCorrection
> > +        , Replacement
> > +        , SpellCheckingExemption
> > +        , Spelling
> > +        , TextMatch
> > +#if ENABLE(TELEPHONE_NUMBER_DETECTION)
> > +        , TelephoneNumber
> > +#endif
> > +#if PLATFORM(IOS)
> > +        , DictationPhraseWithAlternatives
> > +        , DictationResult
> > +#endif
> > +        , DraggedContent
> 
> I would like to see this sorted alphabetically (including "DraggedContent",
> but not including the conditional items. And we should use trailing commas
> instead of leading commas, with the extra one at the end that C++ allows in
> initializer lists. That way we don’t have to have one line different from
> the others.
> 

Will fix.

> > Source/WebCore/editing/Editor.cpp:2752
> > +        DocumentMarker::Spelling, DocumentMarker::CorrectionIndicator, DocumentMarker::SpellCheckingExemption,
> > +        DocumentMarker::DictationAlternatives
> > +#if !PLATFORM(IOS)
> > +        , DocumentMarker::Grammar
> >  #endif
> 
> Trailing commas after each item is a cleaner way to do this since you can
> have an extra comma.


Will fix.
Comment 5 Daniel Bates 2017-07-17 19:43:17 PDT
Committed r219597: <http://trac.webkit.org/changeset/219597>
Comment 6 Konstantin Tokarev 2017-07-17 20:23:57 PDT
This change seems to break WinCairo bot

WebFrame.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl WebCore::DocumentMarkerController::removeMarkers(class WebCore::DocumentMarker::MarkerTypes)" (?removeMarkers@DocumentMarkerController@WebCore@@QEAAXVMarkerTypes@DocumentMarker@2@@Z) referenced in function "public: void __cdecl WebFrame::unmarkAllMisspellings(void)" (?unmarkAllMisspellings@WebFrame@@QEAAXXZ)

https://build.webkit.org/builders/WinCairo%2064-Bit%20Release/builds/4428/steps/compile-webkit/logs/stdio
Comment 7 Darin Adler 2017-07-17 20:27:17 PDT
That looks like a build dependency error that we would get if we tried to link WebKitLegacy against WebCore and had not recompiled WebKitLegacy, rather than a mistake in this patch.

Could force the WinCairo bot to do a clean build, or try to figure out how to fix the build system used by WinCairo to correctly understand this dependency.