mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 526394. Part 24: Create sane nsCaret::GetGeometry API to obsolete nsCaret::GetCaretCoordinates. r=mats
This commit is contained in:
parent
ef60e5fbb0
commit
492587f2be
@ -369,6 +369,48 @@ nsresult nsCaret::GetCaretCoordinates(EViewCoordinates aRelativeToType,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIFrame* nsCaret::GetGeometry(nsISelection* aSelection, nsRect* aRect)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> focusNode;
|
||||
nsresult rv = aSelection->GetFocusNode(getter_AddRefs(focusNode));
|
||||
if (NS_FAILED(rv) || !focusNode)
|
||||
return nsnull;
|
||||
|
||||
PRInt32 focusOffset;
|
||||
rv = aSelection->GetFocusOffset(&focusOffset);
|
||||
if (NS_FAILED(rv))
|
||||
return nsnull;
|
||||
|
||||
nsCOMPtr<nsIContent> contentNode = do_QueryInterface(focusNode);
|
||||
if (!contentNode)
|
||||
return nsnull;
|
||||
|
||||
// find the frame that contains the content node that has focus
|
||||
nsIFrame* theFrame = nsnull;
|
||||
PRInt32 theFrameOffset = 0;
|
||||
|
||||
nsCOMPtr<nsFrameSelection> frameSelection = GetFrameSelection();
|
||||
if (!frameSelection)
|
||||
return nsnull;
|
||||
PRUint8 bidiLevel = frameSelection->GetCaretBidiLevel();
|
||||
rv = GetCaretFrameForNodeOffset(contentNode, focusOffset,
|
||||
frameSelection->GetHint(), bidiLevel,
|
||||
&theFrame, &theFrameOffset);
|
||||
if (NS_FAILED(rv) || !theFrame)
|
||||
return nsnull;
|
||||
|
||||
nsPoint framePos(0, 0);
|
||||
rv = theFrame->GetPointFromOffset(theFrameOffset, &framePos);
|
||||
if (NS_FAILED(rv))
|
||||
return nsnull;
|
||||
|
||||
// now add the frame offset to the view offset, and we're done
|
||||
nscoord height = theFrame->GetSize().height;
|
||||
nscoord width = ComputeMetrics(theFrame, theFrameOffset, height).mCaretWidth;
|
||||
*aRect = nsRect(framePos.x, 0, width, height);
|
||||
return theFrame;
|
||||
}
|
||||
|
||||
void nsCaret::DrawCaretAfterBriefDelay()
|
||||
{
|
||||
// Make sure readonly caret gets drawn again if it needs to be
|
||||
|
@ -104,6 +104,7 @@ class nsCaret : public nsISelectionListener
|
||||
return mReadOnly;
|
||||
}
|
||||
/** GetCaretCoordinates
|
||||
* OBSOLETE use GetGeometry instead.
|
||||
* Get the position of the caret in coordinates relative to the typed
|
||||
* specified (aRelativeToType).
|
||||
* This function is virtual so that it can be used by nsCaretAccessible
|
||||
@ -118,6 +119,16 @@ class nsCaret : public nsISelectionListener
|
||||
PRBool* outIsCollapsed,
|
||||
nsIView **outView);
|
||||
|
||||
/**
|
||||
* Replaces GetCaretCoordinates.
|
||||
* Gets the position and size of the caret that would be drawn for
|
||||
* the focus node/offset of aSelection (assuming it would be drawn,
|
||||
* i.e., disregarding blink status). The geometry is stored in aRect,
|
||||
* and we return the frame aRect is relative to.
|
||||
*/
|
||||
virtual nsIFrame* GetGeometry(nsISelection* aSelection,
|
||||
nsRect* aRect);
|
||||
|
||||
/** EraseCaret
|
||||
* this will erase the caret if its drawn and reset drawn status
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user