Backed out changeset 17e7b969b830 (bug 1713491) for Linux build bustage in gecko/dom/events/ContentEventHandler.cpp. CLOSED TREE

This commit is contained in:
Dorel Luca 2021-06-11 17:52:10 +03:00
Родитель 2be01aafa4
Коммит e1f4d9bb38
12 изменённых файлов: 65 добавлений и 43 удалений

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

@ -236,7 +236,8 @@ nsIntRect HyperTextAccessible::GetBoundsInFrame(nsIFrame* aFrame,
nsRect frameScreenRect = frame->GetScreenRectInAppUnits();
// Get the length of the substring in this frame that we want the bounds for
auto [startFrameTextOffset, endFrameTextOffset] = frame->GetOffsets();
int32_t startFrameTextOffset, endFrameTextOffset;
frame->GetOffsets(startFrameTextOffset, endFrameTextOffset);
int32_t frameTotalTextLength = endFrameTextOffset - startFrameTextOffset;
int32_t seekLength = endContentOffset - startContentOffset;
int32_t frameSubStringLength =

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

@ -3470,7 +3470,8 @@ nsresult Selection::SelectionLanguageChange(bool aLangRTL) {
return NS_ERROR_FAILURE;
}
auto [frameStart, frameEnd] = focusFrame->GetOffsets();
int32_t frameStart, frameEnd;
focusFrame->GetOffsets(frameStart, frameEnd);
RefPtr<nsPresContext> context = GetPresContext();
nsBidiLevel levelBefore, levelAfter;
if (!context) {

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

@ -966,7 +966,9 @@ nsresult ContentEventHandler::ExpandToClusterBoundary(nsIContent* aContent,
nsIFrame* frame = nsFrameSelection::GetFrameForNodeOffset(
aContent, int32_t(*aXPOffset), hint, &offsetInFrame);
if (frame) {
auto [startOffset, endOffset] = frame->GetOffsets();
int32_t startOffset, endOffset;
nsresult rv = frame->GetOffsets(startOffset, endOffset);
NS_ENSURE_SUCCESS(rv, rv);
if (*aXPOffset == static_cast<uint32_t>(startOffset) ||
*aXPOffset == static_cast<uint32_t>(endOffset)) {
return NS_OK;
@ -1626,7 +1628,10 @@ ContentEventHandler::GetLastFrameInRangeForTextRect(const RawRange& aRawRange) {
*nodePosition.Offset(NodePosition::OffsetFilter::kValidOffsets));
}
auto [start, end] = lastFrame->GetOffsets();
int32_t start, end;
if (NS_WARN_IF(NS_FAILED(lastFrame->GetOffsets(start, end)))) {
return FrameAndNodeOffset();
}
// If the start offset in the node is same as the computed offset in the
// node and it's not 0, the frame shouldn't be added to the text rect. So,

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

@ -4646,7 +4646,8 @@ nsRect PresShell::ClipListToRange(nsDisplayListBuilder* aBuilder,
bool atStart = (content == aRange->GetStartContainer());
bool atEnd = (content == aRange->GetEndContainer());
if ((atStart || atEnd) && frame->IsTextFrame()) {
auto [frameStartOffset, frameEndOffset] = frame->GetOffsets();
int32_t frameStartOffset, frameEndOffset;
frame->GetOffsets(frameStartOffset, frameEndOffset);
int32_t hilightStart =
atStart ? std::max(static_cast<int32_t>(aRange->StartOffset()),

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

@ -966,7 +966,8 @@ nsresult nsBidiPresUtils::ResolveParagraph(BidiParagraphData* aBpd) {
break;
}
contentTextLength = content->TextLength();
auto [start, end] = frame->GetOffsets();
int32_t start, end;
frame->GetOffsets(start, end);
NS_ASSERTION(!(contentTextLength < end - start),
"Frame offsets don't fit in content");
fragmentLength = std::min(contentTextLength, end - start);
@ -1245,7 +1246,8 @@ void nsBidiPresUtils::TraverseFrames(nsIFrame* aCurrentFrame,
do {
next = nullptr;
auto [start, end] = frame->GetOffsets();
int32_t start, end;
frame->GetOffsets(start, end);
int32_t endLine = text.FindChar('\n', start);
if (endLine == -1) {
/*
@ -1277,7 +1279,7 @@ void nsBidiPresUtils::TraverseFrames(nsIFrame* aCurrentFrame,
aBpd->AdvanceAndAppendFrame(&frame, aBpd->mCurrentTraverseLine,
&nextSibling);
NS_ASSERTION(frame, "Premature end of continuation chain");
std::tie(start, end) = frame->GetOffsets();
frame->GetOffsets(start, end);
aBpd->AppendString(
Substring(text, start, std::min(end, endLine) - start));
}

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

@ -486,11 +486,11 @@ nsIFrame* nsCaret::GetPaintGeometry(nsRect* aRect) {
}
// If the offset falls outside of the frame, then don't paint the caret.
if (frame->IsTextFrame()) {
auto [startOffset, endOffset] = frame->GetOffsets();
if (startOffset > frameOffset || endOffset < frameOffset) {
return nullptr;
}
int32_t startOffset, endOffset;
if (frame->IsTextFrame() &&
(NS_FAILED(frame->GetOffsets(startOffset, endOffset)) ||
startOffset > frameOffset || endOffset < frameOffset)) {
return nullptr;
}
nsRect caretRect;
@ -659,12 +659,14 @@ nsIFrame* nsCaret::GetCaretFrameForNodeOffset(
aBidiLevel = theFrame->GetEmbeddingLevel();
}
int32_t start;
int32_t end;
nsIFrame* frameBefore;
nsIFrame* frameAfter;
nsBidiLevel levelBefore; // Bidi level of the character before the caret
nsBidiLevel levelAfter; // Bidi level of the character after the caret
auto [start, end] = theFrame->GetOffsets();
theFrame->GetOffsets(start, end);
if (start == 0 || end == 0 || start == theFrameOffset ||
end == theFrameOffset) {
nsPrevNextBidiLevels levels =
@ -692,7 +694,7 @@ nsIFrame* nsCaret::GetCaretFrameForNodeOffset(
if (theFrame != frameBefore) {
if (frameBefore) { // if there is a frameBefore, move into it
theFrame = frameBefore;
std::tie(start, end) = theFrame->GetOffsets();
theFrame->GetOffsets(start, end);
theFrameOffset = end;
} else {
// if there is no frameBefore, we must be at the beginning of
@ -722,7 +724,7 @@ nsIFrame* nsCaret::GetCaretFrameForNodeOffset(
if (frameAfter) {
// if there is a frameAfter, move into it
theFrame = frameAfter;
std::tie(start, end) = theFrame->GetOffsets();
theFrame->GetOffsets(start, end);
theFrameOffset = start;
} else {
// if there is no frameAfter, we must be at the end of the line
@ -751,7 +753,7 @@ nsIFrame* nsCaret::GetCaretFrameForNodeOffset(
!IS_SAME_DIRECTION(aBidiLevel, levelAfter)) {
if (NS_SUCCEEDED(aFrameSelection->GetFrameFromLevel(
frameAfter, eDirNext, aBidiLevel, &theFrame))) {
std::tie(start, end) = theFrame->GetOffsets();
theFrame->GetOffsets(start, end);
levelAfter = theFrame->GetEmbeddingLevel();
if (IS_LEVEL_RTL(aBidiLevel)) // c8: caret to the right of the
// rightmost character
@ -767,7 +769,7 @@ nsIFrame* nsCaret::GetCaretFrameForNodeOffset(
!IS_SAME_DIRECTION(aBidiLevel, levelAfter)) {
if (NS_SUCCEEDED(aFrameSelection->GetFrameFromLevel(
frameBefore, eDirPrevious, aBidiLevel, &theFrame))) {
std::tie(start, end) = theFrame->GetOffsets();
theFrame->GetOffsets(start, end);
levelBefore = theFrame->GetEmbeddingLevel();
if (IS_LEVEL_RTL(aBidiLevel)) // c12: caret to the left of the
// leftmost character

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

@ -7486,7 +7486,9 @@ void nsLayoutUtils::AssertTreeOnlyEmptyNextInFlows(nsIFrame* aSubtreeRoot) {
"frame tree not empty, but caller reported complete status");
// Also assert that text frames map no text.
auto [start, end] = aSubtreeRoot->GetOffsets();
int32_t start, end;
nsresult rv = aSubtreeRoot->GetOffsets(start, end);
NS_ASSERTION(NS_SUCCEEDED(rv), "GetOffsets failed");
// In some cases involving :first-letter, we'll partially unlink a
// continuation in the middle of a continuation chain from its
// previous and next continuations before destroying it, presumably so

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

@ -805,7 +805,7 @@ nsresult nsFrameSelection::MoveCaret(nsDirection aDirection,
// hint to ASSOCIATE_BEFORE to indicate that we want the caret displayed
// at the end of this frame, not at the beginning of the next one.
theFrame = pos.mResultFrame;
std::tie(frameStart, frameEnd) = theFrame->GetOffsets();
theFrame->GetOffsets(frameStart, frameEnd);
currentOffset = pos.mContentOffset;
if (frameEnd == currentOffset && !(frameStart == 0 && frameEnd == 0))
tHint = CARET_ASSOCIATE_BEFORE;
@ -820,7 +820,7 @@ nsresult nsFrameSelection::MoveCaret(nsDirection aDirection,
tHint, &currentOffset);
if (!theFrame) return NS_ERROR_FAILURE;
std::tie(frameStart, frameEnd) = theFrame->GetOffsets();
theFrame->GetOffsets(frameStart, frameEnd);
}
if (context->BidiEnabled()) {
@ -933,26 +933,25 @@ nsPrevNextBidiLevels nsFrameSelection::GetPrevNextBidiLevels(
// Get the level of the frames on each side
nsIFrame* currentFrame;
int32_t currentOffset;
int32_t frameStart, frameEnd;
nsDirection direction;
nsPrevNextBidiLevels levels{};
nsPrevNextBidiLevels levels;
levels.SetData(nullptr, nullptr, 0, 0);
currentFrame = GetFrameForNodeOffset(
aNode, static_cast<int32_t>(aContentOffset), aHint, &currentOffset);
if (!currentFrame) {
return levels;
}
currentFrame =
GetFrameForNodeOffset(aNode, aContentOffset, aHint, &currentOffset);
if (!currentFrame) return levels;
auto [frameStart, frameEnd] = currentFrame->GetOffsets();
currentFrame->GetOffsets(frameStart, frameEnd);
if (0 == frameStart && 0 == frameEnd) {
if (0 == frameStart && 0 == frameEnd)
direction = eDirPrevious;
} else if (frameStart == currentOffset) {
else if (frameStart == currentOffset)
direction = eDirPrevious;
} else if (frameEnd == currentOffset) {
else if (frameEnd == currentOffset)
direction = eDirNext;
} else {
else {
// we are neither at the beginning nor at the end of the frame, so we have
// no worries
nsBidiLevel currentLevel = currentFrame->GetEmbeddingLevel();
@ -1612,7 +1611,9 @@ bool nsFrameSelection::AdjustFrameForLineStart(nsIFrame*& aFrame,
return false;
}
auto [start, end] = aFrame->GetOffsets();
int32_t start;
int32_t end;
aFrame->GetOffsets(start, end);
if (aFrameOffset != end) {
return false;
}
@ -1623,7 +1624,7 @@ bool nsFrameSelection::AdjustFrameForLineStart(nsIFrame*& aFrame,
}
aFrame = nextSibling;
std::tie(start, end) = aFrame->GetOffsets();
aFrame->GetOffsets(start, end);
aFrameOffset = start;
return true;
}

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

@ -939,8 +939,10 @@ void nsIFrame::DestroyFrom(nsIFrame* aDestructRoot,
presShell->FreeFrame(id, this);
}
std::pair<int32_t, int32_t> nsIFrame::GetOffsets() const {
return std::make_pair(0, 0);
nsresult nsIFrame::GetOffsets(int32_t& aStart, int32_t& aEnd) const {
aStart = 0;
aEnd = 0;
return NS_OK;
}
static void CompareLayers(
@ -5214,7 +5216,8 @@ static FrameContentRange GetRangeForFrame(const nsIFrame* aFrame) {
LayoutFrameType type = aFrame->Type();
if (type == LayoutFrameType::Text) {
auto [offset, offsetEnd] = aFrame->GetOffsets();
int32_t offset, offsetEnd;
aFrame->GetOffsets(offset, offsetEnd);
return FrameContentRange(content, offset, offsetEnd);
}
@ -8475,7 +8478,8 @@ static nsContentAndOffset FindLineBreakInText(nsIFrame* aFrame,
return result;
}
auto [startOffset, endOffset] = aFrame->GetOffsets();
int32_t startOffset, endOffset;
aFrame->GetOffsets(startOffset, endOffset);
result.mContent = aFrame->GetContent();
result.mOffset = endOffset - (aDirection == eDirPrevious ? 0 : 1);
return result;
@ -8692,7 +8696,8 @@ nsresult nsIFrame::PeekOffsetForCharacter(nsPeekOffsetStruct* aPos,
// selection, this doesn't matter.
if (peekSearchState == FOUND && current.mMovedOverNonSelectableText &&
(!aPos->mExtend || current.mHasSelectableFrame)) {
auto [start, end] = current.mFrame->GetOffsets();
int32_t start, end;
current.mFrame->GetOffsets(start, end);
current.mOffset = aPos->mDirection == eDirNext ? 0 : end - start;
}
}

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

@ -851,7 +851,7 @@ class nsIFrame : public nsQueryFrame {
* Get the offsets of the frame. most will be 0,0
*
*/
virtual std::pair<int32_t, int32_t> GetOffsets() const;
virtual nsresult GetOffsets(int32_t& start, int32_t& end) const;
/**
* Reset the offsets when splitting frames during Bidi reordering

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

@ -8144,8 +8144,10 @@ nsresult nsTextFrame::CheckVisibility(nsPresContext* aContext,
return NS_OK;
}
std::pair<int32_t, int32_t> nsTextFrame::GetOffsets() const {
return std::make_pair(GetContentOffset(), GetContentEnd());
nsresult nsTextFrame::GetOffsets(int32_t& start, int32_t& end) const {
start = GetContentOffset();
end = GetContentEnd();
return NS_OK;
}
static int32_t FindEndOfPunctuationRun(const nsTextFragment* aFrag,

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

@ -348,7 +348,7 @@ class nsTextFrame : public nsIFrame {
void SetLength(int32_t aLength, nsLineLayout* aLineLayout,
uint32_t aSetLengthFlags = 0);
std::pair<int32_t, int32_t> GetOffsets() const final;
nsresult GetOffsets(int32_t& start, int32_t& end) const final;
void AdjustOffsetsForBidi(int32_t start, int32_t end) final;