mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 1649931 - Part 4: Make GetLineNumber() non-static r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D81955
This commit is contained in:
parent
f92968ee05
commit
fc8e03a55d
@ -8496,11 +8496,11 @@ nsresult nsIFrame::PeekOffset(nsPeekOffsetStruct* aPos) {
|
||||
nsIFrame* blockFrame = this;
|
||||
|
||||
while (NS_FAILED(result)) {
|
||||
int32_t thisLine = nsIFrame::GetLineNumber(
|
||||
blockFrame, aPos->mScrollViewStop, &blockFrame);
|
||||
if (thisLine < 0) return NS_ERROR_FAILURE;
|
||||
int32_t thisLine;
|
||||
MOZ_TRY_VAR(thisLine, blockFrame->GetLineNumber(aPos->mScrollViewStop,
|
||||
&blockFrame));
|
||||
iter = blockFrame->GetLineIterator();
|
||||
NS_ASSERTION(iter, "GetLineNumber() succeeded but no block frame?");
|
||||
MOZ_ASSERT(iter, "GetLineNumber() succeeded but no block frame?");
|
||||
|
||||
int edgeCase = 0; // no edge case. this should look at thisLine
|
||||
|
||||
@ -8592,11 +8592,11 @@ nsresult nsIFrame::PeekOffset(nsPeekOffsetStruct* aPos) {
|
||||
case eSelectEndLine: {
|
||||
// Adjusted so that the caret can't get confused when content changes
|
||||
nsIFrame* blockFrame = AdjustFrameForSelectionStyles(this);
|
||||
int32_t thisLine = nsIFrame::GetLineNumber(
|
||||
blockFrame, aPos->mScrollViewStop, &blockFrame);
|
||||
if (thisLine < 0) return NS_ERROR_FAILURE;
|
||||
int32_t thisLine;
|
||||
MOZ_TRY_VAR(thisLine, blockFrame->GetLineNumber(aPos->mScrollViewStop,
|
||||
&blockFrame));
|
||||
nsAutoLineIterator it = blockFrame->GetLineIterator();
|
||||
NS_ASSERTION(it, "GetLineNumber() succeeded but no block frame?");
|
||||
MOZ_ASSERT(it, "GetLineNumber() succeeded but no block frame?");
|
||||
|
||||
int32_t lineFrameCount;
|
||||
nsIFrame* firstFrame;
|
||||
@ -8764,37 +8764,45 @@ nsresult nsIFrame::CheckVisibility(nsPresContext*, int32_t, int32_t, bool,
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
int32_t nsIFrame::GetLineNumber(nsIFrame* aFrame, bool aLockScroll,
|
||||
nsIFrame** aContainingBlock) {
|
||||
NS_ASSERTION(aFrame, "null aFrame");
|
||||
nsIFrame* blockFrame = aFrame;
|
||||
nsIFrame* thisBlock;
|
||||
Result<int32_t, nsresult> nsIFrame::GetLineNumber(bool aLockScroll,
|
||||
nsIFrame** aContainingBlock) {
|
||||
MOZ_ASSERT(aContainingBlock);
|
||||
|
||||
nsIFrame* parentFrame = this;
|
||||
nsIFrame* frame;
|
||||
nsAutoLineIterator it;
|
||||
nsresult result = NS_ERROR_FAILURE;
|
||||
while (NS_FAILED(result) && blockFrame) {
|
||||
thisBlock = blockFrame;
|
||||
if (thisBlock->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW)) {
|
||||
while (!it && parentFrame) {
|
||||
frame = parentFrame;
|
||||
if (frame->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW)) {
|
||||
// if we are searching for a frame that is not in flow we will not find
|
||||
// it. we must instead look for its placeholder
|
||||
if (thisBlock->HasAnyStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER)) {
|
||||
if (frame->HasAnyStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER)) {
|
||||
// abspos continuations don't have placeholders, get the fif
|
||||
thisBlock = thisBlock->FirstInFlow();
|
||||
frame = frame->FirstInFlow();
|
||||
}
|
||||
frame = frame->GetPlaceholderFrame();
|
||||
if (!frame) {
|
||||
return Err(NS_ERROR_FAILURE);
|
||||
}
|
||||
thisBlock = thisBlock->GetPlaceholderFrame();
|
||||
if (!thisBlock) return -1;
|
||||
}
|
||||
blockFrame = thisBlock->GetParent();
|
||||
result = NS_OK;
|
||||
if (blockFrame) {
|
||||
if (aLockScroll && blockFrame->IsScrollFrame()) return -1;
|
||||
it = blockFrame->GetLineIterator();
|
||||
if (!it) result = NS_ERROR_FAILURE;
|
||||
parentFrame = frame->GetParent();
|
||||
if (parentFrame) {
|
||||
if (aLockScroll && parentFrame->IsScrollFrame()) {
|
||||
return Err(NS_ERROR_FAILURE);
|
||||
}
|
||||
it = parentFrame->GetLineIterator();
|
||||
}
|
||||
}
|
||||
if (!blockFrame || !it) return -1;
|
||||
if (!parentFrame || !it) {
|
||||
return Err(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
if (aContainingBlock) *aContainingBlock = blockFrame;
|
||||
return it->FindLineContaining(thisBlock);
|
||||
*aContainingBlock = parentFrame;
|
||||
int32_t line = it->FindLineContaining(frame);
|
||||
if (line < 0) {
|
||||
return Err(NS_ERROR_FAILURE);
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
||||
Result<bool, nsresult> nsIFrame::IsVisuallyAtLineEdge(
|
||||
@ -8885,9 +8893,9 @@ nsresult nsIFrame::GetFrameFromDirection(
|
||||
while (!selectable) {
|
||||
nsIFrame* blockFrame;
|
||||
|
||||
int32_t thisLine =
|
||||
nsIFrame::GetLineNumber(traversedFrame, aScrollViewStop, &blockFrame);
|
||||
if (thisLine < 0) return NS_ERROR_FAILURE;
|
||||
int32_t thisLine;
|
||||
MOZ_TRY_VAR(thisLine,
|
||||
traversedFrame->GetLineNumber(aScrollViewStop, &blockFrame));
|
||||
|
||||
nsILineIterator* it = blockFrame->GetLineIterator();
|
||||
|
||||
|
@ -3789,14 +3789,14 @@ class nsIFrame : public nsQueryFrame {
|
||||
int32_t aLine,
|
||||
nsDirection aDirection);
|
||||
|
||||
public:
|
||||
// Return the line number of the aFrame, and (optionally) the containing block
|
||||
// frame.
|
||||
// If aScrollLock is true, don't break outside scrollframes when looking for a
|
||||
// containing block frame.
|
||||
static int32_t GetLineNumber(nsIFrame* aFrame, bool aLockScroll,
|
||||
nsIFrame** aContainingBlock = nullptr);
|
||||
Result<int32_t, nsresult> GetLineNumber(
|
||||
bool aLockScroll, nsIFrame** aContainingBlock = nullptr);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Called to see if the children of the frame are visible from indexstart to
|
||||
* index end. This does not change any state. Returns true only if the indexes
|
||||
|
Loading…
Reference in New Issue
Block a user