Commit c9297ecb authored by xiaochengh's avatar xiaochengh Committed by Commit bot

Make Editor::appliedEditing update layout before changing selection

Updating frame selection currently requires clean layout, as it calls
mostBackwardCaretPosition through SelectionAdjuster. One code path that
violates it is from Editor::appliedEditing, which is fixed by this patch.

BUG=679616

Review-Url: https://codereview.chromium.org/2626933002
Cr-Commit-Position: refs/heads/master@{#442881}
parent ce6ec84a
......@@ -25,4 +25,27 @@ test(() => {
'<div contenteditable id="paste"><u>foo bar baz.|</u></div>'
].join(''));
}, 'Copy/paste underlined text.');
test(() => {
assert_not_equals(
window.testRunner, undefined,
'This test requires testRunner.');
assert_selection(
[
'<div contenteditable spellcheck="false">^foo bar baz.|</div>',
'<div contenteditable id="paste"><br></div>'
].join(''),
selection => {
const document = selection.document;
document.execCommand('underline');
document.execCommand('copy');
document.getElementById('paste').focus();
document.execCommand('paste');
},
[
'<div contenteditable spellcheck="false"><u>foo bar baz.</u></div>',
'<div contenteditable id="paste"><u>foo bar baz.|</u></div>'
].join(''));
}, 'Copy/paste underlined text with spell checker off.');
</script>
......@@ -858,6 +858,14 @@ void Editor::appliedEditing(CompositeEditCommand* cmd) {
composition->startingRootEditableElement(),
composition->endingRootEditableElement(), cmd->inputType(),
cmd->textDataForInputEvent(), isComposingFromCommand(cmd));
// TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets
// needs to be audited. See http://crbug.com/590369 for more details.
// The clean layout is consumed by |mostBackwardCaretPosition|, called through
// |changeSelectionAfterCommand|. In the long term, we should postpone visible
// selection canonicalization so that selection update does not need layout.
frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
VisibleSelection newSelection(cmd->endingSelection());
// Don't clear the typing style with this selection change. We do those things
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment