Skip to content

Commit

Permalink
Make <attachment> save button use a single element
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=259086
rdar://112047912

Reviewed by Aditya Keerthi.

Save a bit code by using a pseudo-element instead of another element.

* LayoutTests/platform/ios-wk2/fast/attachment/cocoa/wide-attachment-rendering-expected.txt:
* LayoutTests/platform/mac-wk2/fast/attachment/cocoa/wide-attachment-rendering-expected.txt:
* Source/WebCore/html/HTMLAttachmentElement.cpp:
(WebCore::HTMLAttachmentElement::updateSaveButton):
(WebCore::attachmentSaveIconIdentifier): Deleted.
* Source/WebCore/html/shadow/attachmentElementShadow.css:
(button#attachment-save-button::before):
(div#attachment-save-icon): Deleted.

Canonical link: https://commits.webkit.org/265934@main
  • Loading branch information
nt1m authored and mnutt committed Jul 15, 2023
1 parent 600d54b commit 6eb8d1e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ layer at (195,711) size 230x17
RenderText {#text} at (0,0) size 56x17
text run at (0,0) width 56: "\x{200E}\x{2068}Title\x{2069}\x{200B}.pdf"
layer at (332,411) size 18x40
RenderBlock {DIV} at (0,0) size 18x40 [bgcolor=#007AFF]
RenderBlock (generated) at (0,0) size 18x40 [bgcolor=#007AFF]
RenderText at (0,0) size 0x0
layer at (116,489) size 72x72
RenderBlock {DIV} at (10,10) size 72x72 [bgcolor=#000000]
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ layer at (183,619) size 172x16
RenderText {#text} at (0,0) size 56x16
text run at (0,0) width 56: "\x{200E}\x{2068}Title\x{2069}\x{200B}.pdf"
layer at (270,366) size 14x21
RenderBlock {DIV} at (0,0) size 14x21 [bgcolor=#0000007F]
RenderBlock (generated) at (0,0) size 14x21 [bgcolor=#0000007F]
RenderText at (0,0) size 0x0
layer at (120,433) size 52x52
RenderBlock {DIV} at (14,14) size 52x52 [bgcolor=#000000D8]
8 changes: 0 additions & 8 deletions Source/WebCore/html/HTMLAttachmentElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,6 @@ static const AtomString& attachmentSaveButtonIdentifier()
return identifier;
}

static const AtomString& attachmentSaveIconIdentifier()
{
static MainThreadNeverDestroyed<const AtomString> identifier("attachment-save-icon"_s);
return identifier;
}

static const AtomString& saveAtom()
{
static MainThreadNeverDestroyed<const AtomString> identifier("save"_s);
Expand Down Expand Up @@ -313,8 +307,6 @@ void HTMLAttachmentElement::updateSaveButton(bool show)

m_saveButton = createContainedElement<HTMLButtonElement>(*m_saveArea, attachmentSaveButtonIdentifier());
m_saveButton->addEventListener(eventNames().clickEvent, AttachmentSaveEventListener::create(*this), { });

createContainedElement<HTMLDivElement>(*m_saveButton, attachmentSaveIconIdentifier());
}
}

Expand Down
4 changes: 3 additions & 1 deletion Source/WebCore/html/shadow/attachmentElementShadow.css
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ button#attachment-save-button {
pointer-events: initial;
}

div#attachment-save-icon {
button#attachment-save-button::before {
content: "";
display: block;
/* SF Symbol square-and-arrow-down from https://copysfsymbols.apple.com/bold.html */
mask-image: url('data:image/svg+xml,<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><path d="M9.70427779,59.5060001 L41.1172223,59.5060001 C47.3186112,59.5060001 50.6939445,56.1251112 50.6939445,49.9771805 L50.6939445,23.9525556 C50.6939445,17.8017778 47.3186112,14.4237778 41.1172223,14.4237778 L33.7676667,14.4237778 L33.7676667,21.4344445 L40.3501667,21.4344445 C42.5082223,21.4344445 43.6961112,22.5026667 43.6961112,24.7991667 L43.6961112,49.1306001 C43.6961112,51.4430056 42.5082223,52.4924612 40.3501667,52.4924612 L10.4713889,52.4924612 C8.28600001,52.4924612 7.1253889,51.4430056 7.1253889,49.1306001 L7.1253889,24.7991667 C7.1253889,22.5026667 8.28600001,21.4344445 10.4713889,21.4344445 L17.038,21.4344445 L17.038,14.4237778 L9.70427779,14.4237778 C3.51883334,14.4237778 0.127777778,17.7960556 0.127777778,23.9525556 L0.127777778,49.9771805 C0.127777778,56.1308334 3.51883334,59.5060001 9.70427779,59.5060001 Z M25.4028334,42.3922778 C26.2584445,42.3922778 27.0635,42.1008334 27.8845,41.2957223 L36.8785001,32.6482223 C37.4297223,32.1128889 37.7371112,31.5327778 37.7371112,30.7405556 C37.7371112,29.1907778 36.4414445,28.1172778 35.0055556,28.1172778 C34.2292778,28.1172778 33.4977223,28.4433334 32.9623889,29.0263334 L29.6885556,32.5067223 L28.1213889,34.6002778 L28.5527223,30.6265001 L28.5527223,3.32666667 C28.5527223,1.66016667 27.1617223,0.224444445 25.4028334,0.224444445 C23.6598334,0.224444445 22.2688334,1.66016667 22.2688334,3.32666667 L22.2688334,30.6265001 L22.7001667,34.6031112 L21.1301111,32.5067223 L17.8534445,29.0263334 C17.3209445,28.4433334 16.5735,28.1172778 15.7972778,28.1172778 C14.3584445,28.1172778 13.0816111,29.1907778 13.0816111,30.7405556 C13.0816111,31.5327778 13.3889445,32.1128889 13.9242778,32.6482223 L22.9211667,41.2957223 C23.7552223,42.1008334 24.5631112,42.3922778 25.4028334,42.3922778 Z" transform="translate(6.444 2)"></path></svg>');
mask-repeat: no-repeat;
Expand Down

0 comments on commit 6eb8d1e

Please sign in to comment.