RESOLVED WONTFIX 61050
HTML editing: Font size not written to HTML when identical to default font size
https://bugs.webkit.org/show_bug.cgi?id=61050
Summary HTML editing: Font size not written to HTML when identical to default font size
equinux AG
Reported 2011-05-18 06:59:53 PDT
Summary: When the user sets the font size in an editable text element to the WebView's default font size, that font size does not appear in the resulting HTML. Steps to Reproduce: 1. Load the attached HTML file into a WebView which allows editing. 2. Select all text in the editable text element. 3. Open the Font panel and set the font size to the WebView's default font size (as specified by -[WebPreferences defaultFontSize]; usually 16 pt). 4. Dump the resulting HTML (e.g. via [[[[webView mainFrame] DOMDocument] documentElement] outerHTML]). Expected Results: The text should be wrapped inside a SPAN element specifying the font size (e.g.: <span class="Apple-style-span" style="font-size: 16px;">), as it is for other font sizes, so the document will appear identical when loaded into a different WebView (which may have a different default font size). Actual Results: The font size does not appear in the HTML.
Attachments
Sample HTML file. (229 bytes, text/html)
2011-05-18 07:01 PDT, equinux AG
no flags
equinux AG
Comment 1 2011-05-18 07:01:22 PDT
Created attachment 93908 [details] Sample HTML file.
Aryeh Gregor
Comment 2 2011-08-18 13:20:55 PDT
If you take some HTML and put it in a different page where it has different styles applying to it, it will display differently, yes. If you put it on a page with a different font color, or background color, font, etc., etc. it will display differently. There's no reasonable way to prevent this other than adding <div style="color: ...; font-size: ...; font-face: ...; etc."> inside every editable region, which is impractical. Anyone who saves editable content and restores it in some other place has to make sure the styles match, or else it will definitely look different. So this does not seem like a bug to me. As a general rule, no markup should be added if the styles are already correct. This keeps markup length to a minimum, and it's what's required by the editing spec at this point.
equinux AG
Comment 3 2011-08-19 00:13:01 PDT
The problem we mean is not copying an HTML fragment from one page to another, but opening the same page/document in a different browser (with a different default font size). Suppose the user selects some text and sets the font size to 15 pt. This will add a style="font-size: 15px;" rule, and the text will display at that size in all browsers. Now suppose the user sets the font size to 16 pt (often the default): This will add no CSS, and the text will look different among browsers. The user will probably not understand this. We have just this problem in our product for creating HTML emails: Users open their emails in Apple Mail, whose default font size depends on the preferences, and wonder why their font size changes. This only happens when using 16 pt text.
Aryeh Gregor
Comment 4 2011-08-19 08:48:27 PDT
That's not limited to if the user runs a fontSize command, though. Even if the user doesn't run fontSize, the appearance will change if you view it in a different editor, unless you make sure the size is explicitly specified. The behavior you're proposing means that if the text looks like it's 16px but the user never explicitly told it to be that way, it will change if viewed in a different editor. But if it looks *exactly the same* but at some point the user explicitly specified that it should be 16px, it won't change. And if the user explicitly set some text to 16px and left some alone, all the text will be the same size when they view it, but then when someone else views it some will be one size and some will be another. This is worse than the status quo, if anything.
Ryosuke Niwa
Comment 5 2012-05-01 22:36:37 PDT
I don't think this is an issue we want to / can solve as Aryeh correctly suggested because there are use cases where you want font sizes be adjusted to browser's default font size.
Note You need to log in before you can comment on or make changes to this bug.