Bug 222223 - Preserve information about the origin of the app highlight request
Summary: Preserve information about the origin of the app highlight request
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Megan Gardner
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-02-19 22:36 PST by Megan Gardner
Modified: 2021-03-03 12:29 PST (History)
7 users (show)

See Also:


Attachments
Patch (30.29 KB, patch)
2021-02-19 22:38 PST, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (31.45 KB, patch)
2021-02-22 12:56 PST, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (30.62 KB, patch)
2021-02-22 14:06 PST, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (30.97 KB, patch)
2021-02-22 15:51 PST, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (28.75 KB, patch)
2021-02-22 17:09 PST, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (28.58 KB, patch)
2021-03-02 16:44 PST, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch for landing (28.71 KB, patch)
2021-03-03 10:11 PST, Megan Gardner
ews-feeder: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Megan Gardner 2021-02-19 22:36:44 PST
Preserve information about the origin of the app highlight request
Comment 1 Megan Gardner 2021-02-19 22:38:25 PST
Created attachment 421082 [details]
Patch
Comment 2 Wenson Hsieh 2021-02-22 10:13:55 PST
Comment on attachment 421082 [details]
Patch

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

> Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:1437
> +    [delegate _webView:self storeAppHighlight:wkHighlight.get() inNewGroup:highlight.isNewGroup == WebCore::CreateNewGroupForHighlight::Yes ? YES : NO requestOriginatedInApp:highlight.requestOrigin == WebCore::HighlightRequestOriginatedInApp::Yes ? YES : NO];

Nit - `highlight.isNewGroup == WebCore::CreateNewGroupForHighlight::Yes ? YES : NO` can just be `highlight.isNewGroup == WebCore::CreateNewGroupForHighlight::Yes `.

Also, `requestOrigin` should like it would be a `SecurityOrigin` or `String`, rather than a boolean flag. Can we rename this to something like `requestOriginatedInApp` or `originatedInApp` to match the API selector name?

> Source/WebKit/UIProcess/API/Cocoa/_WKAppHighlightDelegate.h:38
> +- (void)_webView:(WKWebView *)webView storeAppHighlight:(_WKAppHighlight *)highlight inNewGroup:(BOOL)inNewGroup requestOriginatedInApp:(BOOL)requestOrigin WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));

(Here too, w.r.t. `requestOrigin`)

> Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp:1257
> +void WebChromeClient::storeAppHighlight(WebCore::AppHighlight& highlight)

If we make the getters below `const`, then I think `storeAppHighlight` can go back to being `const`.

> Source/WebKit/WebProcess/WebPage/WebPage.h:1405
> +    WebCore::CreateNewGroupForHighlight highlightIsNewGroup() { return m_highlightIsNewGroup; };
> +    WebCore::HighlightRequestOriginatedInApp highlightRequestOrigin() { return m_highlightRequestOrigin; };

Nit - these should be marked `const`.
Comment 3 Wenson Hsieh 2021-02-22 10:16:09 PST
> Also, `requestOrigin` should like it would be a `SecurityOrigin` or
> `String`, rather than a boolean flag. Can we rename this to something like
> `requestOriginatedInApp` or `originatedInApp` to match the API selector name?

(Sorry, I meant to write "sounds like", not "should like")
Comment 4 Megan Gardner 2021-02-22 12:56:28 PST
Created attachment 421229 [details]
Patch
Comment 5 Wenson Hsieh 2021-02-22 13:01:23 PST
Comment on attachment 421229 [details]
Patch

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

> Source/WebKit/UIProcess/Cocoa/SOAuthorization/SOAuthorizationSession.mm:84
> +    auto requestOriginatedInApp = WebCore::SecurityOrigin::create(request.url());
> +    return requestOriginatedInApp->isSameOriginAs(WebCore::SecurityOrigin::create(response.url()).get());

(It looks like this one is an actual SecurityOrigin)
Comment 6 Wenson Hsieh 2021-02-22 13:11:12 PST
Comment on attachment 421229 [details]
Patch

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

r=mews

> Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h:350
> +    void storeAppHighlight(WebCore::AppHighlight&) const final;

Nit - IMO, it's a tad strange for this to take a AppHighlight lvalue reference here, since it's not clear from the name (`storeAppHighlight`) that the method will additionally mutate the given highlight data.

I think this might be better as an rvalue reference instead (WebCore::AppHighlight&&), with `WTFMove`-ing to plumb the highlight along through the client layer, since none of the apparent call sites seem to require the passed-in AppHighlight afterwards.
Comment 7 Wenson Hsieh 2021-02-22 13:12:21 PST
(In reply to Wenson Hsieh from comment #5)
> Comment on attachment 421229 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=421229&action=review
> 
> > Source/WebKit/UIProcess/Cocoa/SOAuthorization/SOAuthorizationSession.mm:84
> > +    auto requestOriginatedInApp = WebCore::SecurityOrigin::create(request.url());
> > +    return requestOriginatedInApp->isSameOriginAs(WebCore::SecurityOrigin::create(response.url()).get());
> 
> (It looks like this one is an actual SecurityOrigin)

...to clarify, we should revert this change before landing.
Comment 8 Megan Gardner 2021-02-22 14:06:35 PST
Created attachment 421238 [details]
Patch
Comment 9 Chris Dumez 2021-02-22 14:21:56 PST
Comment on attachment 421238 [details]
Patch

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

> Source/WebCore/Modules/highlight/AppHighlightStorage.cpp:217
> +void AppHighlightStorage::storeAppHighlight(StaticRange& range)

StaticRange&& (and WTFMove() at the call site)

> Source/WebCore/Modules/highlight/AppHighlightStorage.h:51
> +    WEBCORE_EXPORT void storeAppHighlight(StaticRange&);

StaticRange&&

> Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h:350
> +    void storeAppHighlight(WebCore::AppHighlight&) const final;

WebCore::AppHighlight&&

> Source/WebKit/WebProcess/WebPage/WebPage.h:1401
> +    WebCore::CreateNewGroupForHighlight m_highlightIsNewGroup { WebCore::CreateNewGroupForHighlight::No };

Let's not put data members with the functions. Also, it should probably be private.

> Source/WebKit/WebProcess/WebPage/WebPage.h:1402
> +    WebCore::HighlightRequestOriginatedInApp m_highlightRequestOriginatedInApp { WebCore::HighlightRequestOriginatedInApp::No };

ditto.

> Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h:155
> +    void storeAppHighlight(WebCore::AppHighlight&) const final;

WebCore::AppHighlight&&

> Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm:718
> +void WebChromeClient::storeAppHighlight(WebCore::AppHighlight&) const

WebCore::AppHighlight&&
Comment 10 Megan Gardner 2021-02-22 15:51:58 PST
Created attachment 421253 [details]
Patch
Comment 11 Megan Gardner 2021-02-22 17:09:16 PST
Created attachment 421271 [details]
Patch
Comment 12 Radar WebKit Bug Importer 2021-02-26 22:37:14 PST
<rdar://problem/74821306>
Comment 13 Megan Gardner 2021-03-02 16:44:11 PST
Created attachment 422026 [details]
Patch
Comment 14 Wenson Hsieh 2021-03-03 08:38:36 PST
Comment on attachment 422026 [details]
Patch

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

> Source/WebKit/UIProcess/API/Cocoa/_WKAppHighlightDelegate.h:36
>  - (void)_webView:(WKWebView *)webView storeAppHighlight:(_WKAppHighlight *)highlight inNewGroup:(BOOL)inNewGroup WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));

Since this never shipped, I wonder if we can just remove this version of the UI delegate hook.

> Source/WebKit/WebProcess/WebPage/WebPage.h:1402
> +    WebCore::CreateNewGroupForHighlight highlightIsNewGroup() const { return m_highlightIsNewGroup; };
> +    WebCore::HighlightRequestOriginatedInApp highlightRequestOriginatedInApp() const { return m_highlightRequestOriginatedInApp; };

Nit - don't need semicolons after the two inline functions here.
Comment 15 Megan Gardner 2021-03-03 10:11:53 PST
Created attachment 422108 [details]
Patch for landing
Comment 16 EWS 2021-03-03 10:55:03 PST
Committed r273826: <https://commits.webkit.org/r273826>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 422108 [details].
Comment 17 EWS 2021-03-03 12:29:24 PST
Found 1 new test failure: media/media-fragments/TC0051.html