Bug 20321

Summary: font sizes in design mode
Product: WebKit Reporter: Philip Tucker <ptucker>
Component: HTML EditingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED LATER    
Severity: Normal CC: ahmad.saleem792, apavlov, justin.garcia, ptucker, rniwa, wenson_hsieh
Priority: P2    
Version: 525.x (Safari 3.1)   
Hardware: Mac   
OS: OS X 10.5   

Description Philip Tucker 2008-08-07 13:35:07 PDT
I'm an engineer on Google Documents. We're running into an issue with HTML font translations in Safari, and I was wondering if you could shed some light.

In Safari, in design mode, if we call execCommand('fontSize', size), where size is 1...7, we get:

<span class="Apple-style-span" style="font-size: x-small;">8</span>
<span class="Apple-style-span" style="font-size: small;">10</span>
<span class="Apple-style-span" style="font-size: medium;">12</span>
<span class="Apple-style-span" style="font-size: large;">14</span>
<span class="Apple-style-span" style="font-size: x-large;">18</span>
<span class="Apple-style-span" style="font-size: xx-large;">24</span>
<span class="Apple-style-span" style="font-size: -webkit-xxx-large;">36</span>

No xx-small, and -webkit-xxx-large for the largest size.

The problem is, these font sizes (xx-small ... xx-large) render differently between IE  (which maps xx-small -> 1, x-small -> 2 ... xx-large -> 7) and both Firefox and Safari (which maps xx-small -> 1, x-small -> 1, small -> 2, ... xx-large -> ???). Do you know why this discrepancy exists? Is there a better way to apply font sizes that is more consistent across browsers?
Comment 1 Justin Garcia 2008-08-07 13:39:03 PDT
Hey it looks like we implemented this wrong.  It looks like all of the browsers use a font tag with size="n", even if they've been told to styleWithCSS.
Comment 2 Ahmad Saleem 2022-06-27 17:06:57 PDT
I think following test case do provide bit of coverage for fontsize via execCommand but not when they are defined as "x-small" etc.

Link - https://github.com/WebKit/WebKit/blob/main/LayoutTests/editing/execCommand/query-font-size.html

But if I take the test case and make it JSfiddle as below:

https://jsfiddle.net/1z9etd8k/1/

In Line 92 to 94, I added these "x-small" etc. and got output value of 3 in Safari 15.5 on macOS 12.4, which is same as Chrome Canary 105. But Firefox Nightly 103, does not produce any output for these new additions. Further, Firefox also not produce any output for Manual CSS font-size tests.

I might be doing it completely wrong but I think updating the test and raising this as part of InterOp 2022 for "execCommand" could be good. If I am testing incorrectly or screwed-up on test case update then ignore my comment. Thanks!
Comment 3 Ryosuke Niwa 2022-06-27 21:43:34 PDT
Google docs no longer uses content editable. We can consider better spec'ing fontSize but let's not reuse this bug for that.