Bug 204754 - Add exclusion rule for text manipulation SPI to exclude based on element class
Summary: Add exclusion rule for text manipulation SPI to exclude based on element class
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-12-02 10:13 PST by Louie Livon-Bemel
Modified: 2019-12-04 10:36 PST (History)
7 users (show)

See Also:


Attachments
57398802.patch (13.26 KB, patch)
2019-12-02 15:57 PST, Louie Livon-Bemel
no flags Details | Formatted Diff | Diff
57398802-part-2.patch (12.62 KB, patch)
2019-12-03 10:47 PST, Louie Livon-Bemel
rniwa: review+
Details | Formatted Diff | Diff
57398802-part-3.patch (12.68 KB, patch)
2019-12-04 09:45 PST, Louie Livon-Bemel
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Louie Livon-Bemel 2019-12-02 10:13:57 PST
Add the ability to make exclusion rules that exclude elements from being manipulated based on their class.
Comment 1 Louie Livon-Bemel 2019-12-02 10:15:33 PST
<rdar://problem/57398802>
Comment 2 Louie Livon-Bemel 2019-12-02 15:57:36 PST
Created attachment 384666 [details]
57398802.patch
Comment 3 Louie Livon-Bemel 2019-12-03 10:47:35 PST
Created attachment 384723 [details]
57398802-part-2.patch

Updated match() function to not mutate the element, and therefore left the argument as const.
Comment 4 Ryosuke Niwa 2019-12-03 19:33:58 PST
Comment on attachment 384723 [details]
57398802-part-2.patch

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

> Source/WebCore/ChangeLog:9
> +        Tests added as API tests.

This should instead be:
Tests: TextManipulation.StartTextManipulationApplyInclusionExclusionRulesForClass
       TextManipulation.StartTextManipulationApplyInclusionExclusionRulesForClassAndAttribute

> Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm:248
> +    RetainPtr<_WKTextManipulationConfiguration> configuration = adoptNS([[_WKTextManipulationConfiguration alloc] init]);

Why not auto?

> Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm:279
> +    RetainPtr<_WKTextManipulationConfiguration> configuration = adoptNS([[_WKTextManipulationConfiguration alloc] init]);

Use auto?
Comment 5 Wenson Hsieh 2019-12-03 20:27:55 PST
Comment on attachment 384723 [details]
57398802-part-2.patch

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

> Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm:283
> +        [[[_WKTextManipulationExclusionRule alloc] initExclusion:(BOOL)YES forAttribute:@"data-exclude" value:@"yes"] autorelease],
> +        [[[_WKTextManipulationExclusionRule alloc] initExclusion:(BOOL)NO forAttribute:@"data-exclude" value:@"no"] autorelease],
> +        [[[_WKTextManipulationExclusionRule alloc] initExclusion:(BOOL)YES forClass:@"exclude"] autorelease],

Nit - I don’t think you need the (BOOL) casts here.
Comment 6 Louie Livon-Bemel 2019-12-04 09:12:23 PST
(In reply to Ryosuke Niwa from comment #4)
> Comment on attachment 384723 [details]
> 57398802-part-2.patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=384723&action=review
> 
> > Source/WebCore/ChangeLog:9
> > +        Tests added as API tests.
> 
> This should instead be:
> Tests:
> TextManipulation.StartTextManipulationApplyInclusionExclusionRulesForClass
>       
> TextManipulation.
> StartTextManipulationApplyInclusionExclusionRulesForClassAndAttribute

Fixed.
> 
> > Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm:248
> > +    RetainPtr<_WKTextManipulationConfiguration> configuration = adoptNS([[_WKTextManipulationConfiguration alloc] init]);
> 
> Why not auto?

No specific reason, I'm just in the habit of declaring types since I'm used to Objective-C. I'll make these `auto`.
> 
> > Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm:279
> > +    RetainPtr<_WKTextManipulationConfiguration> configuration = adoptNS([[_WKTextManipulationConfiguration alloc] init]);
> 
> Use auto?
Comment 7 Louie Livon-Bemel 2019-12-04 09:13:20 PST
(In reply to Wenson Hsieh from comment #5)
> Comment on attachment 384723 [details]
> 57398802-part-2.patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=384723&action=review
> 
> > Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm:283
> > +        [[[_WKTextManipulationExclusionRule alloc] initExclusion:(BOOL)YES forAttribute:@"data-exclude" value:@"yes"] autorelease],
> > +        [[[_WKTextManipulationExclusionRule alloc] initExclusion:(BOOL)NO forAttribute:@"data-exclude" value:@"no"] autorelease],
> > +        [[[_WKTextManipulationExclusionRule alloc] initExclusion:(BOOL)YES forClass:@"exclude"] autorelease],
> 
> Nit - I don’t think you need the (BOOL) casts here.

At one point I had a build issue where it didn't understand these values, and a typecast fixed it. I'll see if these are still required.
Comment 8 Louie Livon-Bemel 2019-12-04 09:38:50 PST
(In reply to Louie Livon-Bemel from comment #7)
> (In reply to Wenson Hsieh from comment #5)
> > Comment on attachment 384723 [details]
> > 57398802-part-2.patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=384723&action=review
> > 
> > > Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm:283
> > > +        [[[_WKTextManipulationExclusionRule alloc] initExclusion:(BOOL)YES forAttribute:@"data-exclude" value:@"yes"] autorelease],
> > > +        [[[_WKTextManipulationExclusionRule alloc] initExclusion:(BOOL)NO forAttribute:@"data-exclude" value:@"no"] autorelease],
> > > +        [[[_WKTextManipulationExclusionRule alloc] initExclusion:(BOOL)YES forClass:@"exclude"] autorelease],
> > 
> > Nit - I don’t think you need the (BOOL) casts here.
> 
> At one point I had a build issue where it didn't understand these values,
> and a typecast fixed it. I'll see if these are still required.

Testing this now, I see no issues when removing the typecast. It looks like the tests Ryosuke originally added include the typecast so that's probably why I did too. I'll remove them from my tests though.
Comment 9 Louie Livon-Bemel 2019-12-04 09:45:02 PST
Created attachment 384820 [details]
57398802-part-3.patch
Comment 10 WebKit Commit Bot 2019-12-04 10:36:21 PST
Comment on attachment 384820 [details]
57398802-part-3.patch

Clearing flags on attachment: 384820

Committed r253112: <https://trac.webkit.org/changeset/253112>
Comment 11 WebKit Commit Bot 2019-12-04 10:36:23 PST
All reviewed patches have been landed.  Closing bug.