Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-79778

QtWebengine does not follow the w3c editing spec

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P3: Somewhat important
    • None
    • 5.12.5, 5.13.2, 5.14
    • WebEngine
    • None
    • all platforms
    • All

    Description

      The spec for when you insertParagraph for execCommand is given here:
      https://w3c.github.io/editing/execCommand.html#the-insertparagraph-command-0

      And it clearly states:

      If the local name of the container is "h1", "h2", "h3", "h4", "h5", or "h6" and end-of-line is true, let the new container name be the default single-line container name.

      But the code in qtwebengine/src/3rdparty/chromium/third_party/blink/renderer/core/editing/commands/insert_paragraph_separator_command.cc actually drops the h6 tag in the following two places:

      void InsertParagraphSeparatorCommand::ApplyStyleAfterInsertion(
          Element* original_enclosing_block,
          EditingState* editing_state) {
        // Not only do we break out of header tags, but we also do not preserve the
        // typing style, in order to match other browsers.
        if (original_enclosing_block->HasTagName(h1Tag) ||
            original_enclosing_block->HasTagName(h2Tag) ||
            original_enclosing_block->HasTagName(h3Tag) ||
            original_enclosing_block->HasTagName(h4Tag) ||
            original_enclosing_block->HasTagName(h5Tag)) {
          return;
        }
      
      ...
      
      bool InsertParagraphSeparatorCommand::ShouldUseDefaultParagraphElement(
          Element* enclosing_block) const {
        DCHECK(!GetDocument().NeedsLayoutTreeUpdate());
      
        if (must_use_default_paragraph_element_)
          return true;
      
        // Assumes that if there was a range selection, it was already deleted.
        if (!IsEndOfBlock(EndingVisibleSelection().VisibleStart()))
          return false;
      
        return enclosing_block->HasTagName(h1Tag) ||
               enclosing_block->HasTagName(h2Tag) ||
               enclosing_block->HasTagName(h3Tag) ||
               enclosing_block->HasTagName(h4Tag) ||
               enclosing_block->HasTagName(h5Tag);
      }
      

      This precludes the user who is editing text from using "enter" to break out of the h6 heading tag and all further text typed will appear inside h6 elements that are cloned even copying id attributes making for duplicate ids. This is inconsistent with both the spec and the handling of all h1-h5 elements.

      The fix is simple. Please include this fix in your future releases, especially any follow-on Qt 5.12.X releases.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt_webengine_team Qt WebEngine Team
            kevinhendricks Kevin B. Hendricks
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes