Bug 727942 - ISimpleDOMText::GetCharacterExtents is broken when page is zoomed, r=tbsaunde, f=roc
authorAlexander Surkov <surkov.alexander@gmail.com>
Sat, 20 Oct 2012 10:47:46 +0900
changeset 110985 cb0b143de3aea1cbc6d8935c53230899b0fc4e6c
parent 110984 e8a93741f3e666e3b04e16d5a23a32ad033a44fe
child 110986 196860475fa98dc0ffca0e5c593cd07afc0540ac
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewerstbsaunde
bugs727942
milestone19.0a1
Bug 727942 - ISimpleDOMText::GetCharacterExtents is broken when page is zoomed, r=tbsaunde, f=roc
accessible/src/msaa/TextLeafAccessibleWrap.cpp
--- a/accessible/src/msaa/TextLeafAccessibleWrap.cpp
+++ b/accessible/src/msaa/TextLeafAccessibleWrap.cpp
@@ -194,50 +194,51 @@ TextLeafAccessibleWrap::GetPointFromOffs
 HRESULT
 TextLeafAccessibleWrap::GetCharacterExtents(int32_t aStartOffset,
                                             int32_t aEndOffset,
                                             int32_t* aX,
                                             int32_t* aY,
                                             int32_t* aWidth,
                                             int32_t* aHeight)
 {
+  if (!aX || !aY || !aWidth || !aHeight)
+    return E_INVALIDARG;
+
   *aX = *aY = *aWidth = *aHeight = 0;
 
   if (IsDefunct())
     return CO_E_OBJNOTCONNECTED;
 
-  nsPresContext* presContext = mDoc->PresContext();
-
   nsIFrame *frame = GetFrame();
   NS_ENSURE_TRUE(frame, E_FAIL);
 
   nsPoint startPoint, endPoint;
   nsIFrame *startFrame = GetPointFromOffset(frame, aStartOffset, true, startPoint);
   nsIFrame *endFrame = GetPointFromOffset(frame, aEndOffset, false, endPoint);
   if (!startFrame || !endFrame) {
     return E_FAIL;
   }
-  
-  nsIntRect sum(0, 0, 0, 0);
+
+  nsRect sum;
   nsIFrame *iter = startFrame;
   nsIFrame *stopLoopFrame = endFrame->GetNextContinuation();
   for (; iter != stopLoopFrame; iter = iter->GetNextContinuation()) {
-    nsIntRect rect = iter->GetScreenRectExternal();
-    nscoord start = (iter == startFrame) ? presContext->AppUnitsToDevPixels(startPoint.x) : 0;
-    nscoord end = (iter == endFrame) ? presContext->AppUnitsToDevPixels(endPoint.x) :
-                                       rect.width;
+    nsRect rect = iter->GetScreenRectInAppUnits();
+    nscoord start = (iter == startFrame) ? startPoint.x : 0;
+    nscoord end = (iter == endFrame) ? endPoint.x : rect.width;
     rect.x += start;
     rect.width = end - start;
     sum.UnionRect(sum, rect);
   }
 
-  *aX      = sum.x;
-  *aY      = sum.y;
-  *aWidth  = sum.width;
-  *aHeight = sum.height;
+  nsPresContext* presContext = mDoc->PresContext();
+  *aX = presContext->AppUnitsToDevPixels(sum.x);
+  *aY = presContext->AppUnitsToDevPixels(sum.y);
+  *aWidth = presContext->AppUnitsToDevPixels(sum.width);
+  *aHeight = presContext->AppUnitsToDevPixels(sum.height);
 
   return S_OK;
 }
 
 STDMETHODIMP
 TextLeafAccessibleWrap::get_fontFamily(
     /* [retval][out] */ BSTR __RPC_FAR *aFontFamily)
 {