From c58df5eaefcbc64930f4ec5d5e8ee6bb429bd314 Mon Sep 17 00:00:00 2001 From: "ginn.chen%sun.com" Date: Fri, 16 Dec 2005 05:31:30 +0000 Subject: [PATCH] Bug 317213 magnification loses focus of text element and moves to the top of the application patch by evan.yan@sun.com r=aaronleventhal sr=roc git-svn-id: svn://10.0.0.236/trunk@186155 18797224-902f-48f8-a5cc-f745e15eee43 --- .../accessible/src/atk/nsAccessibleText.cpp | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/mozilla/accessible/src/atk/nsAccessibleText.cpp b/mozilla/accessible/src/atk/nsAccessibleText.cpp index 753ae84b1df..c09a5d6fe17 100644 --- a/mozilla/accessible/src/atk/nsAccessibleText.cpp +++ b/mozilla/accessible/src/atk/nsAccessibleText.cpp @@ -729,23 +729,25 @@ NS_IMETHODIMP nsAccessibleText::GetCharacterExtents(PRInt32 aOffset, rc->GetFontMetrics(fm); NS_ENSURE_TRUE(fm, NS_ERROR_FAILURE); - PRUnichar ch; - if (NS_FAILED(GetCharacterAtOffset(aOffset, &ch))) { - return NS_ERROR_FAILURE; - } - float t2p = context->TwipsToPixels(); - //Getting width - nscoord tmpWidth; - if (NS_SUCCEEDED(rc->GetWidth(ch, tmpWidth))) { - *aWidth = NSTwipsToIntPixels(tmpWidth, t2p); - } + PRUnichar ch; + if (NS_SUCCEEDED(GetCharacterAtOffset(aOffset, &ch))) { + //Getting width + nscoord tmpWidth; + if (NS_SUCCEEDED(rc->GetWidth(ch, tmpWidth))) { + *aWidth = NSTwipsToIntPixels(tmpWidth, t2p); + } - //Getting height - nscoord tmpHeight; - if (NS_SUCCEEDED(fm->GetHeight(tmpHeight))) { - *aHeight = NSTwipsToIntPixels(tmpHeight, t2p); + //Getting height + nscoord tmpHeight; + if (NS_SUCCEEDED(fm->GetHeight(tmpHeight))) { + *aHeight = NSTwipsToIntPixels(tmpHeight, t2p); + } + } + else { + //GetCharacterAtOffset() will fail when there is no text + *aWidth = *aHeight = 0; } //add the width of the string before current char