[Webkit-unassigned] [Bug 204622] New: [GTK] 'FontName' command too aggressive

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Nov 26 08:09:44 PST 2019


https://bugs.webkit.org/show_bug.cgi?id=204622

            Bug ID: 204622
           Summary: [GTK] 'FontName' command too aggressive
           Product: WebKit
           Version: Other
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: WebKitGTK
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: mcrha at redhat.com
                CC: bugs-noreply at webkitgtk.org

I'd like to let the users change font when they edit HTML content. The 'FontName' editing command looks like a natural choice. The only problem with it (apart of not being able to unset the font name, or do not know how to do it) is that it is too aggressive.

Open the WebKit inspector and execute these two commands:

   document.documentElement.innerHTML = "<body><div>aaa</div><div>bbb</div><div>ccc</div></body>";
   document.body.style.fontFamily = "Tahoma";

which produces this HTML structure:

   <body style="font-family: Tahoma;">
      <div>aaa</div>
      <div>bbb</div>
      <div>ccc</div>
   </body>

Then select the middle 'b' of the three 'bbb' by mouse and execute:

   document.execCommand("FontName", false, "monopace");

What I'd expect after this change is to have only the middle 'b' enclosed in the <font> tag, something like this (only the middle paragraph changed):

   <body style="font-family: Tahoma;">
      <div>aaa</div>
      <div>b<font face="monospace">b</font>b</div>
      <div>ccc</div>
   </body>

But the 'FontName' commands changes all around the HTML structure, due to the body's style it seems, and produces this complicated HTML code:

   <body>
      <div style="font-family: Tahoma;">aaa</div>
      <div><font face="Tahoma">b</font><font face="monopace">b</font><font face="Tahoma">b</font></div>
      <div style="font-family: Tahoma;">ccc</div>
   </body>

In other words, it removed the style from the 'body' and propagated it into every paragraph, except of the middle paragraph, where it split the text into three separate <font> tags. It is equivalent here, but maybe I could be able to find more complicated HTML structure where the change would cause format changes. Apart of being unnecessarily complicated HTML code, it also has some consequences, like not being able to undo this in an efficient way (I do my own undo/redo code). I do not think the consequences are the main argument against the current behaviour, I'm only mentioning it as the second reason why this is not ideal.

Not using body's 'style' property, but having defined CSS style with:

   body { font-family:tahoma;}

in <head><style></style></head> makes this work as expected.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20191126/348bb2c0/attachment.htm>


More information about the webkit-unassigned mailing list