зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
6b729f46ac
Коммит
01872d6254
|
@ -5502,23 +5502,16 @@ EditorDOMPoint HTMLEditor::GetWhiteSpaceEndPoint(
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isSpace = false, isNBSP = false;
|
EditorDOMPoint point(aPoint);
|
||||||
nsIContent* newContent = aPoint.Container()->AsContent();
|
if (point.IsInTextNode()) {
|
||||||
int32_t newOffset = *aPoint.Offset(
|
while (!point.IsEndOfContainer()) {
|
||||||
RangeBoundaryBase<PT, RT>::OffsetFilter::kValidOrInvalidOffsets);
|
if (!point.IsCharASCIISpaceOrNBSP()) {
|
||||||
while (newContent) {
|
|
||||||
int32_t offset = -1;
|
|
||||||
nsCOMPtr<nsIContent> content;
|
|
||||||
HTMLEditor::IsNextCharInNodeWhiteSpace(newContent, newOffset, &isSpace,
|
|
||||||
&isNBSP, getter_AddRefs(content),
|
|
||||||
&offset);
|
|
||||||
if (!isSpace && !isNBSP) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
newContent = content;
|
MOZ_ALWAYS_TRUE(point.AdvanceOffset());
|
||||||
newOffset = offset;
|
|
||||||
}
|
}
|
||||||
return EditorDOMPoint(newContent, newOffset);
|
}
|
||||||
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename PT, typename RT>
|
template <typename PT, typename RT>
|
||||||
|
|
|
@ -899,36 +899,6 @@ NS_IMETHODIMP HTMLEditor::NodeIsBlock(nsINode* aNode, bool* aIsBlock) {
|
||||||
return NS_OK;
|
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() {
|
NS_IMETHODIMP HTMLEditor::UpdateBaseURL() {
|
||||||
RefPtr<Document> document = GetDocument();
|
RefPtr<Document> document = GetDocument();
|
||||||
if (NS_WARN_IF(!document)) {
|
if (NS_WARN_IF(!document)) {
|
||||||
|
|
|
@ -799,11 +799,6 @@ class HTMLEditor final : public TextEditor,
|
||||||
*/
|
*/
|
||||||
MOZ_CAN_RUN_SCRIPT nsresult DeleteTableCellContentsWithTransaction();
|
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
|
* extracts an element from the normal flow of the document and
|
||||||
* positions it, and puts it back in the normal flow.
|
* positions it, and puts it back in the normal flow.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче