зеркало из https://github.com/mozilla/gecko-dev.git
Change the GetRelativedWindowCoordinate to return the botton of the cursor, instead of the top of the cursor. We need this to make Mac IME candidcate window popup in a more reasonable place. author=sfraser. r=ftang
This commit is contained in:
Родитель
7699111c7e
Коммит
e4d5acd2de
|
@ -221,16 +221,16 @@ NS_IMETHODIMP nsCaret::GetWindowRelativeCoordinates(nsPoint& outCoordinates, PRB
|
||||||
if (!contentNode)
|
if (!contentNode)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
// find the frame that contains the content node that has focus
|
|
||||||
nsIFrame* theFrame = nsnull;
|
|
||||||
|
|
||||||
//get frame selection and find out what frame to use...
|
//get frame selection and find out what frame to use...
|
||||||
nsCOMPtr<nsIFrameSelection> frameSelection;
|
nsCOMPtr<nsIFrameSelection> frameSelection;
|
||||||
err = mPresShell->GetFrameSelection(getter_AddRefs(frameSelection));
|
err = mPresShell->GetFrameSelection(getter_AddRefs(frameSelection));
|
||||||
if (NS_FAILED(err) || !frameSelection)
|
if (NS_FAILED(err) || !frameSelection)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
// find the frame that contains the content node that has focus
|
||||||
|
nsIFrame* theFrame = nsnull;
|
||||||
err = frameSelection->GetFrameForNodeOffset(contentNode, focusOffset, &theFrame);
|
err = frameSelection->GetFrameForNodeOffset(contentNode, focusOffset, &theFrame);
|
||||||
if (NS_FAILED(err))
|
if (NS_FAILED(err) || !theFrame)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
nsPoint viewOffset(0, 0);
|
nsPoint viewOffset(0, 0);
|
||||||
|
@ -266,6 +266,11 @@ NS_IMETHODIMP nsCaret::GetWindowRelativeCoordinates(nsPoint& outCoordinates, PRB
|
||||||
nsPoint framePos(0, 0);
|
nsPoint framePos(0, 0);
|
||||||
theFrame->GetPointFromOffset(presContext, rendContext, focusOffset, &framePos);
|
theFrame->GetPointFromOffset(presContext, rendContext, focusOffset, &framePos);
|
||||||
|
|
||||||
|
nsRect frameRect;
|
||||||
|
theFrame->GetRect(frameRect);
|
||||||
|
|
||||||
|
// add the frame height, to get the bottom of the frame
|
||||||
|
framePos.y += frameRect.height;
|
||||||
// now add the frame offset to the view offset, and we're done
|
// now add the frame offset to the view offset, and we're done
|
||||||
viewOffset += framePos;
|
viewOffset += framePos;
|
||||||
outCoordinates = viewOffset;
|
outCoordinates = viewOffset;
|
||||||
|
|
|
@ -221,16 +221,16 @@ NS_IMETHODIMP nsCaret::GetWindowRelativeCoordinates(nsPoint& outCoordinates, PRB
|
||||||
if (!contentNode)
|
if (!contentNode)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
// find the frame that contains the content node that has focus
|
|
||||||
nsIFrame* theFrame = nsnull;
|
|
||||||
|
|
||||||
//get frame selection and find out what frame to use...
|
//get frame selection and find out what frame to use...
|
||||||
nsCOMPtr<nsIFrameSelection> frameSelection;
|
nsCOMPtr<nsIFrameSelection> frameSelection;
|
||||||
err = mPresShell->GetFrameSelection(getter_AddRefs(frameSelection));
|
err = mPresShell->GetFrameSelection(getter_AddRefs(frameSelection));
|
||||||
if (NS_FAILED(err) || !frameSelection)
|
if (NS_FAILED(err) || !frameSelection)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
// find the frame that contains the content node that has focus
|
||||||
|
nsIFrame* theFrame = nsnull;
|
||||||
err = frameSelection->GetFrameForNodeOffset(contentNode, focusOffset, &theFrame);
|
err = frameSelection->GetFrameForNodeOffset(contentNode, focusOffset, &theFrame);
|
||||||
if (NS_FAILED(err))
|
if (NS_FAILED(err) || !theFrame)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
nsPoint viewOffset(0, 0);
|
nsPoint viewOffset(0, 0);
|
||||||
|
@ -266,6 +266,11 @@ NS_IMETHODIMP nsCaret::GetWindowRelativeCoordinates(nsPoint& outCoordinates, PRB
|
||||||
nsPoint framePos(0, 0);
|
nsPoint framePos(0, 0);
|
||||||
theFrame->GetPointFromOffset(presContext, rendContext, focusOffset, &framePos);
|
theFrame->GetPointFromOffset(presContext, rendContext, focusOffset, &framePos);
|
||||||
|
|
||||||
|
nsRect frameRect;
|
||||||
|
theFrame->GetRect(frameRect);
|
||||||
|
|
||||||
|
// add the frame height, to get the bottom of the frame
|
||||||
|
framePos.y += frameRect.height;
|
||||||
// now add the frame offset to the view offset, and we're done
|
// now add the frame offset to the view offset, and we're done
|
||||||
viewOffset += framePos;
|
viewOffset += framePos;
|
||||||
outCoordinates = viewOffset;
|
outCoordinates = viewOffset;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче