WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
236386
Send icons to the WebContent process for rendering of the attachment element
https://bugs.webkit.org/show_bug.cgi?id=236386
Summary
Send icons to the WebContent process for rendering of the attachment element
Per Arne Vollan
Reported
2022-02-09 11:27:12 PST
In order to avoid connecting to the Icon Services daemon in the WebContent process, we should send the icons for the attachment element to the WebContent process from the UI process.
Attachments
Patch
(17.63 KB, patch)
2022-02-09 12:43 PST
,
Per Arne Vollan
no flags
Details
Formatted Diff
Diff
Patch
(21.82 KB, patch)
2022-02-09 13:38 PST
,
Per Arne Vollan
no flags
Details
Formatted Diff
Diff
Patch
(24.48 KB, patch)
2022-02-10 08:59 PST
,
Per Arne Vollan
no flags
Details
Formatted Diff
Diff
Patch
(23.73 KB, patch)
2022-02-10 11:07 PST
,
Per Arne Vollan
no flags
Details
Formatted Diff
Diff
Patch
(27.69 KB, patch)
2022-02-11 08:45 PST
,
Per Arne Vollan
no flags
Details
Formatted Diff
Diff
Patch
(55.90 KB, patch)
2022-02-11 16:58 PST
,
Per Arne Vollan
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(58.16 KB, patch)
2022-02-11 19:05 PST
,
Per Arne Vollan
no flags
Details
Formatted Diff
Diff
Patch
(50.85 KB, patch)
2022-02-14 09:41 PST
,
Per Arne Vollan
no flags
Details
Formatted Diff
Diff
Patch
(51.19 KB, patch)
2022-02-15 07:39 PST
,
Per Arne Vollan
no flags
Details
Formatted Diff
Diff
Patch
(51.45 KB, patch)
2022-02-15 15:19 PST
,
Per Arne Vollan
darin
: review+
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(52.14 KB, patch)
2022-02-16 10:03 PST
,
Per Arne Vollan
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(52.16 KB, patch)
2022-02-16 10:08 PST
,
Per Arne Vollan
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(52.14 KB, patch)
2022-02-16 10:14 PST
,
Per Arne Vollan
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(52.29 KB, patch)
2022-02-16 10:35 PST
,
Per Arne Vollan
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(52.28 KB, patch)
2022-02-16 11:11 PST
,
Per Arne Vollan
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(52.29 KB, patch)
2022-02-16 11:31 PST
,
Per Arne Vollan
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(52.25 KB, patch)
2022-02-16 15:39 PST
,
Per Arne Vollan
no flags
Details
Formatted Diff
Diff
Show Obsolete
(14)
View All
Add attachment
proposed patch, testcase, etc.
Per Arne Vollan
Comment 1
2022-02-09 12:43:38 PST
Created
attachment 451428
[details]
Patch
Per Arne Vollan
Comment 2
2022-02-09 12:44:16 PST
(In reply to Per Arne Vollan from
comment #1
)
> Created
attachment 451428
[details]
> Patch
WIP patch.
Per Arne Vollan
Comment 3
2022-02-09 13:38:23 PST
Created
attachment 451438
[details]
Patch
Per Arne Vollan
Comment 4
2022-02-10 08:59:14 PST
Created
attachment 451545
[details]
Patch
Per Arne Vollan
Comment 5
2022-02-10 11:07:48 PST
Created
attachment 451576
[details]
Patch
Per Arne Vollan
Comment 6
2022-02-11 08:45:35 PST
Created
attachment 451701
[details]
Patch
Geoffrey Garen
Comment 7
2022-02-11 11:27:32 PST
Comment on
attachment 451701
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=451701&action=review
Patch looks good to me; probably want a graphics expert to double-check too.
> Source/WebCore/html/HTMLAttachmentElement.cpp:267 > +void HTMLAttachmentElement::updateIcon(const RefPtr<Image>& icon, const WebCore::FloatSize& size)
icon => iconSize
Tim Horton
Comment 8
2022-02-11 11:51:27 PST
Comment on
attachment 451701
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=451701&action=review
> Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm:328 > + return convertPlatformImageToBitmap(image.get(), WebCore::IntSize(400, 400));
I guess this is your solution to not knowing destination resolution; is the icon any blurrier than it used to be, now that you're using a big representation and scaling it down instead of letting the multi-representation platform image do the right thing?
Per Arne Vollan
Comment 9
2022-02-11 16:58:16 PST
Created
attachment 451758
[details]
Patch
Per Arne Vollan
Comment 10
2022-02-11 16:58:48 PST
(In reply to Geoffrey Garen from
comment #7
)
> Comment on
attachment 451701
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=451701&action=review
> > Patch looks good to me; probably want a graphics expert to double-check too. > > > Source/WebCore/html/HTMLAttachmentElement.cpp:267 > > +void HTMLAttachmentElement::updateIcon(const RefPtr<Image>& icon, const WebCore::FloatSize& size) > > icon => iconSize
Fixed. Thanks for reviewing!
Per Arne Vollan
Comment 11
2022-02-11 17:00:01 PST
(In reply to Tim Horton from
comment #8
)
> Comment on
attachment 451701
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=451701&action=review
> > > Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm:328 > > + return convertPlatformImageToBitmap(image.get(), WebCore::IntSize(400, 400)); > > I guess this is your solution to not knowing destination resolution; is the > icon any blurrier than it used to be, now that you're using a big > representation and scaling it down instead of letting the > multi-representation platform image do the right thing?
I have not noticed the icons being blurry when rendered on iOS or macOS. Thanks for reviewing!
Per Arne Vollan
Comment 12
2022-02-11 19:05:32 PST
Created
attachment 451769
[details]
Patch
Per Arne Vollan
Comment 13
2022-02-14 09:41:33 PST
Created
attachment 451915
[details]
Patch
Geoffrey Garen
Comment 14
2022-02-14 09:47:08 PST
Comment on
attachment 451701
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=451701&action=review
>>> Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm:328 >>> + return convertPlatformImageToBitmap(image.get(), WebCore::IntSize(400, 400)); >> >> I guess this is your solution to not knowing destination resolution; is the icon any blurrier than it used to be, now that you're using a big representation and scaling it down instead of letting the multi-representation platform image do the right thing? > > I have not noticed the icons being blurry when rendered on iOS or macOS. > > Thanks for reviewing!
Should we consider trying to send the destination resolution from the WebContent process, or is that something that WebKit just doesn't know?
Per Arne Vollan
Comment 15
2022-02-14 10:35:57 PST
(In reply to Geoffrey Garen from
comment #14
)
> Comment on
attachment 451701
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=451701&action=review
> > >>> Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm:328 > >>> + return convertPlatformImageToBitmap(image.get(), WebCore::IntSize(400, 400)); > >> > >> I guess this is your solution to not knowing destination resolution; is the icon any blurrier than it used to be, now that you're using a big representation and scaling it down instead of letting the multi-representation platform image do the right thing? > > > > I have not noticed the icons being blurry when rendered on iOS or macOS. > > > > Thanks for reviewing! > > Should we consider trying to send the destination resolution from the > WebContent process, or is that something that WebKit just doesn't know?
Yes, that is a good point. I think we actually know the destination rect. I will look into this! Thanks for reviewing!
Per Arne Vollan
Comment 16
2022-02-15 07:39:00 PST
Created
attachment 452024
[details]
Patch
Per Arne Vollan
Comment 17
2022-02-15 15:19:34 PST
Created
attachment 452100
[details]
Patch
Darin Adler
Comment 18
2022-02-15 15:35:10 PST
Comment on
attachment 452100
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=452100&action=review
> Source/WebCore/html/HTMLAttachmentElement.cpp:283 > + return;
Don’t need this at the end of a function.
> Source/WebCore/html/HTMLAttachmentElement.cpp:289 > +FloatSize HTMLAttachmentElement::iconSize() const > +{ > + return m_iconSize; > +}
Consider putting this in the header.
> Source/WebCore/page/EmptyAttachmentElementClient.h:40 > + virtual void requestAttachmentIcon(const String&, const FloatSize&) { }
Should be marked "final", not "virtual".
> Source/WebCore/rendering/RenderThemeIOS.h:71 > + WEBCORE_EXPORT static RetainPtr<UIImage> iconForAttachment(const String& fileName, const String& attachmentType, const String& title, FloatSize&);
I suggest returning a structure containing both the UIImage and FloatSize rather than using an out argument for that.
> Source/WebCore/rendering/RenderThemeIOS.mm:1805 > + auto name = fileName; > + if (name.isEmpty()) > + name = title; > + > + [documentInteractionController setName:name];
I would have written: [documentInteractionController setName:fileName.isEmpty() ? title : fileName]; Rather than the 4 line version.
> Source/WebCore/rendering/RenderThemeMac.mm:2567 > +RetainPtr<NSImage> RenderThemeMac::iconForAttachment(const String& fileName, const String& attachmentType, const String& title)
Seems a shame that we need all those different nsImage() lines rather than a function returning an Icon and another that returns the NSImage *.
> Source/WebCore/rendering/RenderThemeMac.mm:2574 > +ALLOW_DEPRECATED_DECLARATIONS_BEGIN > + if (auto icon = Icon::createIconForUTI(kUTTypeFolder)) > + return icon->nsImage(); > +ALLOW_DEPRECATED_DECLARATIONS_END
Just moved code, but I have some ideas for refinement. Would have been nice to wrap this around just a single line: ALLOW_DEPRECATED_DECLARATIONS_BEGIN auto type = kUTTypeFolder; ALLOW_DEPRECATED_DECLARATIONS_END
> Source/WebCore/rendering/RenderThemeMac.mm:2576 > + String UTI;
I would have just named this "type".
> Source/WebCore/rendering/RenderThemeMac.mm:2592 > + NSString *fileExtension = [static_cast<NSString *>(title) pathExtension];
I recommend using a local variable instead of a static_cast, and auto instead of writing out the type. NSString *cocoaTitle = title; if (auto fileExtension = cocoaTitle.pathExtension; fileExtension.length) {
> Source/WebCore/rendering/RenderThemeMac.mm:2601 > + return nullptr;
Should be nil instead of nullptr.
> Source/WebCore/rendering/RenderThemeMac.mm:2641 > + String attachmentType = attachment.attachmentElement().attachmentType();
This looks unused. Why compute it if we aren’t using it?
> Source/WebCore/rendering/RenderThemeMac.mm:2649 > + if (context.paintingDisabled()) > + return;
Do we want to request the icon if painting is disabled?
> Source/WebCore/rendering/RenderThemeMac.mm:2651 > + auto nsImage = icon->nsImage();
Can just call this "image", no need to say "nsImage".
> Source/WebKit/UIProcess/WebPageProxy.cpp:10207 > + auto icon = iconForAttachment(fileName, contentType, title, size); > + if (icon)
if (auto icon = ...)
> Source/WebKit/WebProcess/WebCoreSupport/WebAttachmentElementClient.h:39 > + WebAttachmentElementClient(WebPage&);
This should be marked explicit.
> Source/WebKit/WebProcess/WebCoreSupport/WebAttachmentElementClient.h:40 > + virtual ~WebAttachmentElementClient() { }
This is not needed or helpful.
> Source/WebKit/WebProcess/WebCoreSupport/WebAttachmentElementClient.h:42 > + virtual void requestAttachmentIcon(const String& identifier, const WebCore::FloatSize&);
This should be marked "final", not "virtual". Also could probably be private.
> Source/WebKit/WebProcess/WebPage/WebPage.cpp:7330 > + if (RefPtr<ShareableBitmap> icon = !iconHandle.isNull() ? ShareableBitmap::create(iconHandle) : nullptr)
This can be RefPtr or auto, I think, doesn’t need to be RefPtr<ShareableBitmap>.
Per Arne Vollan
Comment 19
2022-02-15 15:43:13 PST
(In reply to Darin Adler from
comment #18
)
> Comment on
attachment 452100
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=452100&action=review
> > > Source/WebCore/html/HTMLAttachmentElement.cpp:283 > > + return; > > Don’t need this at the end of a function. > > > Source/WebCore/html/HTMLAttachmentElement.cpp:289 > > +FloatSize HTMLAttachmentElement::iconSize() const > > +{ > > + return m_iconSize; > > +} > > Consider putting this in the header. > > > Source/WebCore/page/EmptyAttachmentElementClient.h:40 > > + virtual void requestAttachmentIcon(const String&, const FloatSize&) { } > > Should be marked "final", not "virtual". > > > Source/WebCore/rendering/RenderThemeIOS.h:71 > > + WEBCORE_EXPORT static RetainPtr<UIImage> iconForAttachment(const String& fileName, const String& attachmentType, const String& title, FloatSize&); > > I suggest returning a structure containing both the UIImage and FloatSize > rather than using an out argument for that. > > > Source/WebCore/rendering/RenderThemeIOS.mm:1805 > > + auto name = fileName; > > + if (name.isEmpty()) > > + name = title; > > + > > + [documentInteractionController setName:name]; > > I would have written: > > [documentInteractionController setName:fileName.isEmpty() ? title : > fileName]; > > Rather than the 4 line version. > > > Source/WebCore/rendering/RenderThemeMac.mm:2567 > > +RetainPtr<NSImage> RenderThemeMac::iconForAttachment(const String& fileName, const String& attachmentType, const String& title) > > Seems a shame that we need all those different nsImage() lines rather than a > function returning an Icon and another that returns the NSImage *. > > > Source/WebCore/rendering/RenderThemeMac.mm:2574 > > +ALLOW_DEPRECATED_DECLARATIONS_BEGIN > > + if (auto icon = Icon::createIconForUTI(kUTTypeFolder)) > > + return icon->nsImage(); > > +ALLOW_DEPRECATED_DECLARATIONS_END > > Just moved code, but I have some ideas for refinement. Would have been nice > to wrap this around just a single line: > > ALLOW_DEPRECATED_DECLARATIONS_BEGIN > auto type = kUTTypeFolder; > ALLOW_DEPRECATED_DECLARATIONS_END > > > Source/WebCore/rendering/RenderThemeMac.mm:2576 > > + String UTI; > > I would have just named this "type". > > > Source/WebCore/rendering/RenderThemeMac.mm:2592 > > + NSString *fileExtension = [static_cast<NSString *>(title) pathExtension]; > > I recommend using a local variable instead of a static_cast, and auto > instead of writing out the type. > > NSString *cocoaTitle = title; > if (auto fileExtension = cocoaTitle.pathExtension; fileExtension.length) > { > > > Source/WebCore/rendering/RenderThemeMac.mm:2601 > > + return nullptr; > > Should be nil instead of nullptr. > > > Source/WebCore/rendering/RenderThemeMac.mm:2641 > > + String attachmentType = attachment.attachmentElement().attachmentType(); > > This looks unused. Why compute it if we aren’t using it? > > > Source/WebCore/rendering/RenderThemeMac.mm:2649 > > + if (context.paintingDisabled()) > > + return; > > Do we want to request the icon if painting is disabled? > > > Source/WebCore/rendering/RenderThemeMac.mm:2651 > > + auto nsImage = icon->nsImage(); > > Can just call this "image", no need to say "nsImage". > > > Source/WebKit/UIProcess/WebPageProxy.cpp:10207 > > + auto icon = iconForAttachment(fileName, contentType, title, size); > > + if (icon) > > if (auto icon = ...) > > > Source/WebKit/WebProcess/WebCoreSupport/WebAttachmentElementClient.h:39 > > + WebAttachmentElementClient(WebPage&); > > This should be marked explicit. > > > Source/WebKit/WebProcess/WebCoreSupport/WebAttachmentElementClient.h:40 > > + virtual ~WebAttachmentElementClient() { } > > This is not needed or helpful. > > > Source/WebKit/WebProcess/WebCoreSupport/WebAttachmentElementClient.h:42 > > + virtual void requestAttachmentIcon(const String& identifier, const WebCore::FloatSize&); > > This should be marked "final", not "virtual". Also could probably be private. > > > Source/WebKit/WebProcess/WebPage/WebPage.cpp:7330 > > + if (RefPtr<ShareableBitmap> icon = !iconHandle.isNull() ? ShareableBitmap::create(iconHandle) : nullptr) > > This can be RefPtr or auto, I think, doesn’t need to be > RefPtr<ShareableBitmap>.
Thanks for reviewing! I will address the comments in the upcoming patch.
Per Arne Vollan
Comment 20
2022-02-16 10:03:25 PST
Created
attachment 452204
[details]
Patch
Per Arne Vollan
Comment 21
2022-02-16 10:08:07 PST
Created
attachment 452205
[details]
Patch
Per Arne Vollan
Comment 22
2022-02-16 10:14:54 PST
Created
attachment 452207
[details]
Patch
Per Arne Vollan
Comment 23
2022-02-16 10:35:27 PST
Created
attachment 452209
[details]
Patch
Per Arne Vollan
Comment 24
2022-02-16 11:11:24 PST
Created
attachment 452215
[details]
Patch
Radar WebKit Bug Importer
Comment 25
2022-02-16 11:28:18 PST
<
rdar://problem/89038014
>
Per Arne Vollan
Comment 26
2022-02-16 11:31:09 PST
Created
attachment 452216
[details]
Patch
EWS
Comment 27
2022-02-16 15:30:40 PST
Tools/Scripts/svn-apply failed to apply
attachment 452216
[details]
to trunk. Please resolve the conflicts and upload a new patch.
Per Arne Vollan
Comment 28
2022-02-16 15:39:56 PST
Created
attachment 452260
[details]
Patch
EWS
Comment 29
2022-02-16 19:48:01 PST
Committed
r289994
(
247380@main
): <
https://commits.webkit.org/247380@main
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 452260
[details]
.
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