Bug 226267 - Refactor some data detector code in WebCore::Frame
Summary: Refactor some data detector code in WebCore::Frame
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Wenson Hsieh
URL:
Keywords: InRadar
Depends on: 226227
Blocks: 226274
  Show dependency treegraph
 
Reported: 2021-05-26 07:52 PDT by Wenson Hsieh
Modified: 2021-05-27 13:26 PDT (History)
13 users (show)

See Also:


Attachments
Patch (26.24 KB, patch)
2021-05-26 08:33 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
For EWS (26.09 KB, patch)
2021-05-27 11:43 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Fix GTK/WPE build (26.10 KB, patch)
2021-05-27 12:26 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wenson Hsieh 2021-05-26 07:52:35 PDT
.
Comment 1 Wenson Hsieh 2021-05-26 08:33:47 PDT
Created attachment 429763 [details]
Patch
Comment 2 Andy Estes 2021-05-27 11:06:40 PDT
Comment on attachment 429763 [details]
Patch

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

> Source/WebCore/editing/cocoa/DataDetection.h:44
> +class HTMLElement;

Nit: T < i

> Source/WebCore/editing/cocoa/DataDetection.h:49
> +#if ENABLE(IMAGE_EXTRACTION)
> +struct ImageExtractionDataDetectorInfo;
> +#endif

Nit: I think it's preferable to remove the `#if` here since the forward declaration is harmless even when `ENABLE(IMAGE_EXTRACTION)` is false.

> Source/WebCore/page/Frame.h:104
> +#if ENABLE(DATA_DETECTION)
> +class DataDetectionResultsStorage;
> +#endif

Nit: ditto

> Source/WebCore/page/cocoa/DataDetectionResultsStorage.h:43
> +    DataDetectionResultsStorage() = default;
> +    ~DataDetectionResultsStorage() = default;

Nit: I think the compiler will generate a default constructor and destructor without you having to declare them.

Note that you also get a default copy constructor. Do you want to `WTF_MAKE_NONCOPYABLE` this?
Comment 3 Devin Rousso 2021-05-27 11:14:42 PDT
Comment on attachment 429763 [details]
Patch

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

r=me as well :)

> Source/WebCore/page/Frame.cpp:112
> +#include "DataDetectionResultsStorage.h"

I'd remove the `#if` here since everything in the file has the same `#if`.

> Source/WebKit/WebProcess/WebPage/WebPage.cpp:273
> +#include <WebCore/DataDetectionResultsStorage.h>

ditto

> Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:156
> +#if ENABLE(DATA_DETECTION)

ditto
Comment 4 Wenson Hsieh 2021-05-27 11:21:56 PDT
Comment on attachment 429763 [details]
Patch

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

>> Source/WebCore/editing/cocoa/DataDetection.h:44
>> +class HTMLElement;
> 
> Nit: T < i

Fixed!

>> Source/WebCore/editing/cocoa/DataDetection.h:49
>> +#endif
> 
> Nit: I think it's preferable to remove the `#if` here since the forward declaration is harmless even when `ENABLE(IMAGE_EXTRACTION)` is false.

Sounds good! Removed the guard.

>> Source/WebCore/page/Frame.cpp:112
>> +#include "DataDetectionResultsStorage.h"
> 
> I'd remove the `#if` here since everything in the file has the same `#if`.

👍🏻

>> Source/WebCore/page/Frame.h:104
>> +#endif
> 
> Nit: ditto

Fixed!

>> Source/WebCore/page/cocoa/DataDetectionResultsStorage.h:43
>> +    ~DataDetectionResultsStorage() = default;
> 
> Nit: I think the compiler will generate a default constructor and destructor without you having to declare them.
> 
> Note that you also get a default copy constructor. Do you want to `WTF_MAKE_NONCOPYABLE` this?

Good catch! Removed the ctor/dtor definitions here, and added `WTF_MAKE_NONCOPYABLE(DataDetectionResultsStorage)` above.

>> Source/WebKit/WebProcess/WebPage/WebPage.cpp:273
>> +#include <WebCore/DataDetectionResultsStorage.h>
> 
> ditto

I'm not actually sure this will work, since DataDetectionResultsStorage.h (which is in a cocoa directory in WebCore) would need to be added to the Headers.cmake list to be exported. I'll see what the bots think!

>> Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:156
>> +#if ENABLE(DATA_DETECTION)
> 
> ditto

Sounds good! Removed the #if (this is Cocoa-specific code so this should be safe to import).
Comment 5 Wenson Hsieh 2021-05-27 11:43:16 PDT
Created attachment 429906 [details]
For EWS
Comment 6 Wenson Hsieh 2021-05-27 12:26:40 PDT
Created attachment 429911 [details]
Fix GTK/WPE build
Comment 7 EWS 2021-05-27 13:25:10 PDT
Committed r278175 (238218@main): <https://commits.webkit.org/238218@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 429911 [details].
Comment 8 Radar WebKit Bug Importer 2021-05-27 13:26:17 PDT
<rdar://problem/78584057>