Commit eb2857b0 authored by yoichio's avatar yoichio Committed by Commit bot

[Editing] Use VisiblePosition stardOfWord for textarea in spell checker.

TextControlElement::{start,end}{Word,Sentence}() without VisiblePosition was
 introduced for Speedometor benchmark.(crrev.com/db6862d1)
Since, editing is now pipeline friendly and hoisting have not caused regression,
 we need not have such optimization functions.

This CL clean up code path. I will clean up the functions later.

BUG=639528

Review-Url: https://codereview.chromium.org/2533213003
Cr-Commit-Position: refs/heads/master@{#435592}
parent d28b98c7
<!DOCTYPE html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../assert_selection.js"></script>
<script>
test(() => {
assert_selection(
'<div><textarea readonly="readonly">|foo</textarea></div>',
selection => selection.extend(selection.document.querySelector('div'), 0),
'<div><textarea readonly="readonly">|foo</textarea></div>');
});
</script>
......@@ -72,10 +72,6 @@ bool isPositionInTextArea(const Position& position) {
return isHTMLTextAreaElement(textControl);
}
bool isSelectionInTextFormControl(const VisibleSelection& selection) {
return !!enclosingTextControl(selection.start());
}
static bool isSpellCheckingEnabledFor(const Position& position) {
if (position.isNull())
return false;
......@@ -900,16 +896,9 @@ void SpellChecker::respondToChangedSelection(
VisibleSelection newAdjacentWords;
const VisibleSelection newSelection = frame().selection().selection();
if (isSelectionInTextFormControl(newSelection)) {
const Position newStart = newSelection.start();
newAdjacentWords.setWithoutValidation(
TextControlElement::startOfWord(newStart),
TextControlElement::endOfWord(newStart));
} else {
if (newSelection.isContentEditable()) {
newAdjacentWords =
createVisibleSelection(selectWord(newSelection.visibleStart()));
}
if (newSelection.isContentEditable()) {
newAdjacentWords =
createVisibleSelection(selectWord(newSelection.visibleStart()));
}
// When typing we check spelling elsewhere, so don't redo it here.
......
......@@ -137,6 +137,7 @@ class CORE_EXPORT TextControlElement : public HTMLFormControlElementWithState {
String directionForFormData() const;
// TODO(yoichio): Remove these functions.
// These functions don't cause synchronous layout and SpellChecker uses
// them to improve performance.
// Passed |Position| must point inside of a text form control.
......
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