Bug 1627175 - part 63: Get rid of `HTMLEditor::IsNextCharInNodeWhiteSpace()` r=m_kato

Similarly, it's called only by `HTMLEditor::GetWhiteSpaceEndPoint()` and
it returns after point of last white-space if and only if the given point
container is a text node and the offset is not end of the text node.
Therefore, we can reimplement it in the caller simply.

Differential Revision: https://phabricator.services.mozilla.com/D115172
This commit is contained in:
Masayuki Nakano 2021-05-18 02:05:34 +00:00
Родитель 6b729f46ac
Коммит 01872d6254
3 изменённых файлов: 8 добавлений и 50 удалений

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

@ -5502,23 +5502,16 @@ EditorDOMPoint HTMLEditor::GetWhiteSpaceEndPoint(
return point;
}
bool isSpace = false, isNBSP = false;
nsIContent* newContent = aPoint.Container()->AsContent();
int32_t newOffset = *aPoint.Offset(
RangeBoundaryBase<PT, RT>::OffsetFilter::kValidOrInvalidOffsets);
while (newContent) {
int32_t offset = -1;
nsCOMPtr<nsIContent> content;
HTMLEditor::IsNextCharInNodeWhiteSpace(newContent, newOffset, &isSpace,
&isNBSP, getter_AddRefs(content),
&offset);
if (!isSpace && !isNBSP) {
break;
EditorDOMPoint point(aPoint);
if (point.IsInTextNode()) {
while (!point.IsEndOfContainer()) {
if (!point.IsCharASCIISpaceOrNBSP()) {
break;
}
MOZ_ALWAYS_TRUE(point.AdvanceOffset());
}
newContent = content;
newOffset = offset;
}
return EditorDOMPoint(newContent, newOffset);
return point;
}
template <typename PT, typename RT>

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

@ -899,36 +899,6 @@ NS_IMETHODIMP HTMLEditor::NodeIsBlock(nsINode* aNode, bool* aIsBlock) {
return NS_OK;
}
/**
* IsNextCharInNodeWhiteSpace() checks the adjacent content in the same node to
* see if following selection is white-space or nbsp.
*/
void HTMLEditor::IsNextCharInNodeWhiteSpace(nsIContent* aContent,
int32_t aOffset, bool* outIsSpace,
bool* outIsNBSP,
nsIContent** outNode,
int32_t* outOffset) {
MOZ_ASSERT(aContent && outIsSpace && outIsNBSP);
MOZ_ASSERT((outNode && outOffset) || (!outNode && !outOffset));
*outIsSpace = false;
*outIsNBSP = false;
if (outNode && outOffset) {
*outNode = nullptr;
*outOffset = -1;
}
if (aContent->IsText() && (uint32_t)aOffset < aContent->Length()) {
char16_t ch = aContent->GetText()->CharAt(aOffset);
*outIsSpace = nsCRT::IsAsciiSpace(ch);
*outIsNBSP = (ch == kNBSP);
if (outNode && outOffset) {
NS_IF_ADDREF(*outNode = aContent);
// yes, this is _past_ the character
*outOffset = aOffset + 1;
}
}
}
NS_IMETHODIMP HTMLEditor::UpdateBaseURL() {
RefPtr<Document> document = GetDocument();
if (NS_WARN_IF(!document)) {

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

@ -799,11 +799,6 @@ class HTMLEditor final : public TextEditor,
*/
MOZ_CAN_RUN_SCRIPT nsresult DeleteTableCellContentsWithTransaction();
static void IsNextCharInNodeWhiteSpace(nsIContent* aContent, int32_t aOffset,
bool* outIsSpace, bool* outIsNBSP,
nsIContent** outNode = nullptr,
int32_t* outOffset = 0);
/**
* extracts an element from the normal flow of the document and
* positions it, and puts it back in the normal flow.