Bug 254031 - [GTK] Editor: Odd SPAN added on text input
Summary: [GTK] Editor: Odd SPAN added on text input
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-16 10:12 PDT by Milan Crha
Modified: 2023-05-08 08:52 PDT (History)
2 users (show)

See Also:


Attachments
test-html-editor.c (18.18 KB, text/plain)
2023-03-16 10:12 PDT, Milan Crha
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Milan Crha 2023-03-16 10:12:07 PDT
Created attachment 465461 [details]
test-html-editor.c

There is added an odd SPAN element when editing a text. Even I cannot reproduce this under MiniBrowser, I can reproduce it consistently with the attached program, which depends on the Evolution HTML editor.

Steps:
1) install evolution-devel package (aka development files for the evolution package)
2) download, compile and run the attached test-html-editor.c file - the first line of it contains a comment with a command to do it
3) press for example 'a' key

Current result:
The HTML structure looks like this:
   <body>
     <div><span style="background-color: inherit;">a</span></div>
   </body>

Expected result:
   <body>
     <div>a</div>
   </body>

This is reproducible with 2.35.1-1 release onwards (including 2.38.x series), the last version where it does not misbehave is 2.34.6-1.

Notes:

The test program has enabled Ctrl+Shift+I to open the WebKit Inspector, or one can use View->Inspector from the menu, for easier debugging.

An interesting thing is that it does not do it always. For example when I run the test program as:

   ./test-html-editor "<div>b</div>"

then the press of the 'a' constructs:

    <body>
      <div>ab</div>
    </body>

as expected.

Another interesting thing is that when I comment these lines:

		// make sure there is a selection
		if (!document.getSelection().anchorNode || document.getSelection().anchorNode.tagName == "HTML") {
			document.getSelection().setPosition(document.body.firstChild ? document.body.firstChild : document.body, 0);
		}

in /usr/share/evolution/webkit/e-editor.js , in function EvoEditor.initializeContent, then it does not misbehave too, but it can write text in a wrong place.

Alternatively, when I execute (re-run) the command `document.getSelection().setPosition(document.body.firstChild ? document.body.firstChild : document.body, 0);` in the WebKit console after the editor is opened, then it also does not misbehave.
Comment 1 Michael Catanzaro 2023-05-08 08:52:46 PDT
My to-do list says I'm supposed to bisect this, but I'm not going to find time to do it. Sorry. :( Going back so far as 2.34 is inconvenient.