mail.yahoo.com: caret jumps to the start of the editor after outdenting out of a blockquote#35764
Closed
whsieh wants to merge 1 commit intoWebKit:mainfrom
Closed
mail.yahoo.com: caret jumps to the start of the editor after outdenting out of a blockquote#35764whsieh wants to merge 1 commit intoWebKit:mainfrom
whsieh wants to merge 1 commit intoWebKit:mainfrom
Conversation
…ng out of a blockquote https://bugs.webkit.org/show_bug.cgi?id=282142 rdar://138081308 Reviewed by NOBODY (OOPS!). In Yahoo Mail, when outdenting to break out of a blockquote element on a line with no content, the selection is always reset to the top of the editable root. Suppose we're outdenting in a simple DOM tree on Yahoo: ``` --- Safari, before outdenting <DIV contenteditable> # Yahoo's root editable element <BLOCKQUOTE> <DIV> Some text <DIV> # Selection is here. <BR> ``` 1. When clicking on the outdent menu item in Yahoo Mail's UI, Yahoo triggers the `Outdent` editing command. This executes as expected, and places the ending selection in the correct location (depicted below). ``` --- Safari, after outdenting <DIV contenteditable> # Yahoo's root editable element <BLOCKQUOTE> <DIV> Some text # Selection is here <BR> ``` 2. However, immediately after this happens, the menu dismisses, which runs some other JavaScript that then attempts to "fix up" the DOM selection. This JavaScript always moves the selection to the start of the editable root, under 3 specific conditions: a. The selection is collapsed. b. The editable root (i.e. contenteditable `DIV` marked above) has ≥1 children. c. The selection anchor (`getSelection().anchorNode`) is equal to the editable root. Because we satisfy all three of the above conditions (since the selection anchor is at offset 1 in the editable root), the selection is always moved to the start, which causes the bug. This does not happen in Chrome because, upon initially creating the `BLOCKQUOTE` element, Chrome wraps the block quote in a redundant `DIV`, such that the final selection after outdenting places the selection anchor under this new `DIV` rather than under the root editable. ``` --- Chrome, after outdenting <DIV contenteditable> # Editable root <DIV> <BLOCKQUOTE> <DIV> Some text # Selection is here <BR> ``` This also does not happen in Firefox because outdenting creates a DOM structure that has an extra `DIV` element containing the `BR`: ``` --- Firefox, after outdenting <DIV contenteditable> # Editable root <BLOCKQUOTE> <DIV> Some text <DIV> # Selection is here <BR> ``` To address this issue, this patch aligns our behavior to Firefox, by ensuring that the placeholder `BR` above is additionally contained in the document's default paragraph element (i.e. `DIV`). This approach is a bit less intrusive of a change than adjusting to match Chrome's behavior, but still avoids this bug. * LayoutTests/editing/execCommand/outdent-break-with-style-expected.txt: * LayoutTests/editing/execCommand/outdent-regular-blockquote-expected.txt: * LayoutTests/editing/execCommand/outdent-selection-expected.txt: * LayoutTests/editing/execCommand/unindent-nested-blockquote-with-inner-div-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/editing/run/outdent_1-1000-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/editing/run/outdent_2001-last-expected.txt: Rebaseline various layout tests to account for the new behavior. * Source/WebCore/editing/IndentOutdentCommand.cpp: (WebCore::IndentOutdentCommand::outdentParagraph):
Collaborator
|
EWS run on current version of this PR (hash 055682d) Details |
Member
Author
|
This PR branch was opened by accident (doesn't match the bugzilla bug) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
055682d
055682d