WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
250003
[GTK] Clipboard copy adds extra font style
https://bugs.webkit.org/show_bug.cgi?id=250003
Summary
[GTK] Clipboard copy adds extra font style
Milan Crha
Reported
2023-01-02 07:15:25 PST
Moving from downstream bug report:
https://gitlab.gnome.org/GNOME/evolution/-/issues/1950
When copying HTML content and pasting it back to the WebKitWebView, the pasted text can contain a font size style attribute (in pixels), which was not set in the selected text. This can negatively affect the content rendering, thus it would be better to not add the font size information into the clipboard if the selected text uses either the default font size or the parent element has set a font size. The font size declared in pixels is also rather wrong (consider when composing on a normal DPI screen and then viewing the content on a hiDPI screen - untested here, but I guess the pixel-defined font size will be smaller than the text without the font size definition, even though the normal DPI screen will show the texts in the same size, thus it'll be unnoticed by the text editor). Steps: a) run: MiniBrowser --editor-mode b) press Ctrl+Shift+I to open the Inspector, right-click the <head> element and choose Edit->HTML from the context menu and change its content to: <head><style>body { font-size: 11pt; }</style></head> c) focus the text body d) type: line one<enter> e) type: line two<enter> f) highlight "line two" g) press Ctrl+C h) put cursor after "line one' i) press <enter> j) press Ctrl+V See the HTML source [1], the pasted text contains font size information as a style attribute. Note the `Default font size` setting is set to 16 here and when I change the font size <style> of the body element (in the <head>) to 16px (from 11pt), then the font declaration is not included in the pasted text. Tested with 2.38.2 of the WebKitGTK. [1] HTML source: <html> <head><style>body { font-size: 11pt; }</style></head> <body> line 1 <div><span style="font-size: 14.666667px;">line 2</span><br> <div>line 2</div> </div> </body> </html>
Attachments
Add attachment
proposed patch, testcase, etc.
Milan Crha
Comment 1
2023-03-30 08:38:13 PDT
This is even worse with WebKitGTK 2.40.0, it doesn't add the SPAN, but it adds styles to each DIV/element with the appearance information, even when those values are defaults: `<div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Cantarell; font-size: 14.666667px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4); -webkit-text-stroke-width: 0px; text-decoration: none;">Pasted Text</div>`
Milan Crha
Comment 2
2023-03-30 22:37:35 PDT
> This is even worse with WebKitGTK 2.40.0
Aha, it's not a new thing in the 2.40.0, there depends whether a single-line text or multiple lines are copied.
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