mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1048752. Part 37: GetGeometryForFrame should return a rect instead of an nsresult. r=tn
--HG-- extra : rebase_source : f49846cc50de2a3a616a991d81b38bf6c1d9a2c5
This commit is contained in:
parent
a1a66a6c41
commit
5bedbd1447
@ -273,16 +273,20 @@ void nsCaret::SetCaretReadOnly(bool inMakeReadonly)
|
||||
SchedulePaint();
|
||||
}
|
||||
|
||||
/* static */ nsresult
|
||||
/* static */ nsRect
|
||||
nsCaret::GetGeometryForFrame(nsIFrame* aFrame,
|
||||
int32_t aFrameOffset,
|
||||
nsRect* aRect,
|
||||
nscoord* aBidiIndicatorSize)
|
||||
{
|
||||
nsPoint framePos(0, 0);
|
||||
nsRect rect;
|
||||
nsresult rv = aFrame->GetPointFromOffset(aFrameOffset, &framePos);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
if (NS_FAILED(rv)) {
|
||||
if (aBidiIndicatorSize) {
|
||||
*aBidiIndicatorSize = 0;
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
|
||||
nsIFrame* frame = aFrame->GetContentInsertionFrame();
|
||||
if (!frame) {
|
||||
@ -303,7 +307,7 @@ nsCaret::GetGeometryForFrame(nsIFrame* aFrame,
|
||||
nscoord height = ascent + descent;
|
||||
framePos.y = baseline - ascent;
|
||||
Metrics caretMetrics = ComputeMetrics(aFrame, aFrameOffset, height);
|
||||
*aRect = nsRect(framePos, nsSize(caretMetrics.mCaretWidth, height));
|
||||
rect = nsRect(framePos, nsSize(caretMetrics.mCaretWidth, height));
|
||||
|
||||
// Clamp the x-position to be within our scroll frame. If we don't, then it
|
||||
// clips us, and we don't appear at all. See bug 335560.
|
||||
@ -313,20 +317,21 @@ nsCaret::GetGeometryForFrame(nsIFrame* aFrame,
|
||||
// First, use the scrollFrame to get at the scrollable view that we're in.
|
||||
nsIScrollableFrame *sf = do_QueryFrame(scrollFrame);
|
||||
nsIFrame *scrolled = sf->GetScrolledFrame();
|
||||
nsRect caretInScroll = *aRect + aFrame->GetOffsetTo(scrolled);
|
||||
nsRect caretInScroll = rect + aFrame->GetOffsetTo(scrolled);
|
||||
|
||||
// Now see if thet caret extends beyond the view's bounds. If it does,
|
||||
// then snap it back, put it as close to the edge as it can.
|
||||
nscoord overflow = caretInScroll.XMost() -
|
||||
scrolled->GetVisualOverflowRectRelativeToSelf().width;
|
||||
if (overflow > 0)
|
||||
aRect->x -= overflow;
|
||||
if (overflow > 0) {
|
||||
rect.x -= overflow;
|
||||
}
|
||||
}
|
||||
|
||||
if (aBidiIndicatorSize)
|
||||
if (aBidiIndicatorSize) {
|
||||
*aBidiIndicatorSize = caretMetrics.mBidiIndicatorSize;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
|
||||
static nsIFrame*
|
||||
@ -372,7 +377,7 @@ nsCaret::GetGeometry(nsISelection* aSelection, nsRect* aRect)
|
||||
nsIFrame* frame = GetFrameAndOffset(
|
||||
static_cast<Selection*>(aSelection), nullptr, 0, &frameOffset);
|
||||
if (frame) {
|
||||
GetGeometryForFrame(frame, frameOffset, aRect, nullptr);
|
||||
*aRect = GetGeometryForFrame(frame, frameOffset, nullptr);
|
||||
}
|
||||
return frame;
|
||||
}
|
||||
@ -818,12 +823,7 @@ nsCaret::ComputeCaretRects(nsIFrame* aFrame, int32_t aFrameOffset,
|
||||
NS_ASSERTION(aFrame, "Should have a frame here");
|
||||
|
||||
nscoord bidiIndicatorSize;
|
||||
nsresult rv =
|
||||
GetGeometryForFrame(aFrame, aFrameOffset, aCaretRect, &bidiIndicatorSize);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aCaretRect = *aHookRect = nsRect();
|
||||
return;
|
||||
}
|
||||
*aCaretRect = GetGeometryForFrame(aFrame, aFrameOffset, &bidiIndicatorSize);
|
||||
|
||||
// on RTL frames the right edge of mCaretRect must be equal to framePos
|
||||
const nsStyleVisibility* vis = aFrame->StyleVisibility();
|
||||
|
@ -164,10 +164,9 @@ protected:
|
||||
};
|
||||
static Metrics ComputeMetrics(nsIFrame* aFrame, int32_t aOffset,
|
||||
nscoord aCaretHeight);
|
||||
static nsresult GetGeometryForFrame(nsIFrame* aFrame,
|
||||
int32_t aFrameOffset,
|
||||
nsRect* aRect,
|
||||
nscoord* aBidiIndicatorSize);
|
||||
static nsRect GetGeometryForFrame(nsIFrame* aFrame,
|
||||
int32_t aFrameOffset,
|
||||
nscoord* aBidiIndicatorSize);
|
||||
|
||||
void ComputeCaretRects(nsIFrame* aFrame, int32_t aFrameOffset,
|
||||
nsRect* aCaretRect, nsRect* aHookRect);
|
||||
|
Loading…
Reference in New Issue
Block a user