Bug 1705598 - part 3: Make `WSRunScanner::GetPreviousEditableCharPoint()` and `WSRunScanner::GetInclusiveNextEditableCharPoint()` take editing host instead of `HTMLEditor` r=m_kato

Depends on D112503

Differential Revision: https://phabricator.services.mozilla.com/D112504
This commit is contained in:
Masayuki Nakano 2021-04-19 23:25:45 +00:00
Родитель a7b87b61b1
Коммит 265f751419
2 изменённых файлов: 14 добавлений и 10 удалений

Просмотреть файл

@ -1810,7 +1810,8 @@ HTMLEditor::GetPreviousCharPointDataForNormalizingWhiteSpaces(
HTMLEditor::GetPreviousCharPointType(aPoint));
}
EditorDOMPointInText previousCharPoint =
WSRunScanner::GetPreviousEditableCharPoint(*this, aPoint);
WSRunScanner::GetPreviousEditableCharPoint(GetActiveEditingHost(),
aPoint);
if (!previousCharPoint.IsSet()) {
return CharPointData::InDifferentTextNode(CharPointType::TextEnd);
}
@ -1827,7 +1828,8 @@ HTMLEditor::GetInclusiveNextCharPointDataForNormalizingWhiteSpaces(
return CharPointData::InSameTextNode(HTMLEditor::GetCharPointType(aPoint));
}
EditorDOMPointInText nextCharPoint =
WSRunScanner::GetInclusiveNextEditableCharPoint(*this, aPoint);
WSRunScanner::GetInclusiveNextEditableCharPoint(GetActiveEditingHost(),
aPoint);
if (!nextCharPoint.IsSet()) {
return CharPointData::InDifferentTextNode(CharPointType::TextEnd);
}
@ -1916,10 +1918,12 @@ void HTMLEditor::ExtendRangeToDeleteWithNormalizingWhiteSpaces(
// are, check whether they are collapsible or not. Note that we shouldn't
// touch white-spaces in different text nodes for performance, but we need
// adjacent text node's first or last character information in some cases.
Element* editingHost = GetActiveEditingHost();
EditorDOMPointInText precedingCharPoint =
WSRunScanner::GetPreviousEditableCharPoint(*this, aStartToDelete);
WSRunScanner::GetPreviousEditableCharPoint(editingHost, aStartToDelete);
EditorDOMPointInText followingCharPoint =
WSRunScanner::GetInclusiveNextEditableCharPoint(*this, aEndToDelete);
WSRunScanner::GetInclusiveNextEditableCharPoint(editingHost,
aEndToDelete);
// Blink-compat: Normalize white-spaces in first node only when not removing
// its last character or no text nodes follow the first node.
// If removing last character of first node and there are

Просмотреть файл

@ -316,13 +316,13 @@ class MOZ_STACK_CLASS WSRunScanner final {
*/
template <typename PT, typename CT>
static EditorDOMPointInText GetInclusiveNextEditableCharPoint(
const HTMLEditor& aHTMLEditor, const EditorDOMPointBase<PT, CT>& aPoint) {
dom::Element* aEditingHost, const EditorDOMPointBase<PT, CT>& aPoint) {
if (aPoint.IsInTextNode() && !aPoint.IsEndOfContainer() &&
HTMLEditUtils::IsSimplyEditableNode(*aPoint.ContainerAsText())) {
return EditorDOMPointInText(aPoint.ContainerAsText(), aPoint.Offset());
}
WSRunScanner scanner(aHTMLEditor.GetActiveEditingHost(), aPoint);
return scanner.GetInclusiveNextEditableCharPoint(aPoint);
return WSRunScanner(aEditingHost, aPoint)
.GetInclusiveNextEditableCharPoint(aPoint);
}
/**
@ -331,14 +331,14 @@ class MOZ_STACK_CLASS WSRunScanner final {
*/
template <typename PT, typename CT>
static EditorDOMPointInText GetPreviousEditableCharPoint(
const HTMLEditor& aHTMLEditor, const EditorDOMPointBase<PT, CT>& aPoint) {
dom::Element* aEditingHost, const EditorDOMPointBase<PT, CT>& aPoint) {
if (aPoint.IsInTextNode() && !aPoint.IsStartOfContainer() &&
HTMLEditUtils::IsSimplyEditableNode(*aPoint.ContainerAsText())) {
return EditorDOMPointInText(aPoint.ContainerAsText(),
aPoint.Offset() - 1);
}
WSRunScanner scanner(aHTMLEditor.GetActiveEditingHost(), aPoint);
return scanner.GetPreviousEditableCharPoint(aPoint);
return WSRunScanner(aEditingHost, aPoint)
.GetPreviousEditableCharPoint(aPoint);
}
/**