| Index: fpdfsdk/src/fsdk_annothandler.cpp
 | 
| diff --git a/fpdfsdk/src/fsdk_annothandler.cpp b/fpdfsdk/src/fsdk_annothandler.cpp
 | 
| index 50ef9cf3c1e4a68f1a2f58ea9764297289cc0432..ebdd67e4ef18f14c6504aaa052d44323a96db737 100644
 | 
| --- a/fpdfsdk/src/fsdk_annothandler.cpp
 | 
| +++ b/fpdfsdk/src/fsdk_annothandler.cpp
 | 
| @@ -309,35 +309,18 @@ FX_BOOL         CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(CPDFSDK_Annot* pAnnot,
 | 
|          if (pAnnotHandler->OnSetFocus(pAnnot, nFlag))
 | 
|          {
 | 
|              CPDFSDK_PageView* pPage = pAnnot->GetPageView();
 | 
| -            ASSERT(pPage != NULL);
 | 
| -
 | 
|              pPage->GetSDKDocument();
 | 
| -    //      pDocument->SetTopmostAnnot(pAnnot);
 | 
| -
 | 
|              return TRUE;
 | 
|          }
 | 
| -        else
 | 
| -        {
 | 
| -            return FALSE;
 | 
| -        }
 | 
|      }
 | 
| -
 | 
|      return FALSE;
 | 
|  }
 | 
|  
 | 
|  FX_BOOL         CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag)
 | 
|  {
 | 
| -    ASSERT(pAnnot != NULL);
 | 
| -
 | 
| +    ASSERT(pAnnot);
 | 
|      if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
 | 
| -    {
 | 
| -        if (pAnnotHandler->OnKillFocus(pAnnot, nFlag))
 | 
| -        {
 | 
| -            return TRUE;
 | 
| -        }
 | 
| -        else
 | 
| -            return FALSE;
 | 
| -    }
 | 
| +        return pAnnotHandler->OnKillFocus(pAnnot, nFlag);
 | 
|  
 | 
|      return FALSE;
 | 
|  }
 | 
| @@ -360,9 +343,8 @@ CPDF_Rect   CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox(CPDFSDK_PageView *pPage
 | 
|  {
 | 
|      ASSERT(pAnnot);
 | 
|      if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
 | 
| -    {
 | 
|          return pAnnotHandler->GetViewBBox(pPageView, pAnnot);
 | 
| -    }
 | 
| +
 | 
|      return pAnnot->GetRect();
 | 
|  }
 | 
|  
 | 
| @@ -371,7 +353,7 @@ FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView *pPageView, CP
 | 
|      ASSERT(pAnnot);
 | 
|      if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot))
 | 
|      {
 | 
| -        if(pAnnotHandler->CanAnswer(pAnnot))
 | 
| +        if (pAnnotHandler->CanAnswer(pAnnot))
 | 
|              return pAnnotHandler->HitTest(pPageView, pAnnot, point);
 | 
|      }
 | 
|      return FALSE;
 | 
| @@ -407,38 +389,26 @@ CPDFSDK_Annot*  CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,F
 | 
|  
 | 
|  FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot)
 | 
|  {
 | 
| -    ASSERT(pAnnot);
 | 
|      ASSERT(pAnnot->GetType() == "Widget");
 | 
| -    CFX_ByteString sSubType = pAnnot->GetSubType();
 | 
| -
 | 
| -    if (sSubType == BFFT_SIGNATURE)
 | 
| -    {
 | 
| -    }
 | 
| -    else
 | 
| -    {
 | 
| -        CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
 | 
| -        if (!pWidget->IsVisible()) return FALSE;
 | 
| +    if (pAnnot->GetSubType() == BFFT_SIGNATURE)
 | 
| +        return FALSE;
 | 
|  
 | 
| -        int nFieldFlags = pWidget->GetFieldFlags();
 | 
| -        if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) return FALSE;
 | 
| -        if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON)
 | 
| -            return TRUE;
 | 
| -        else
 | 
| -        {
 | 
| -            CPDF_Page* pPage = pWidget->GetPDFPage();
 | 
| -            ASSERT(pPage != NULL);
 | 
| +    CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
 | 
| +    if (!pWidget->IsVisible())
 | 
| +            return FALSE;
 | 
|  
 | 
| -            CPDF_Document* pDocument = pPage->m_pDocument;
 | 
| -            ASSERT(pDocument != NULL);
 | 
| +    int nFieldFlags = pWidget->GetFieldFlags();
 | 
| +    if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY)
 | 
| +        return FALSE;
 | 
|  
 | 
| -            FX_DWORD dwPermissions = pDocument->GetUserPermissions();
 | 
| -            return (dwPermissions&FPDFPERM_FILL_FORM) ||
 | 
| -                (dwPermissions&FPDFPERM_ANNOT_FORM) ||
 | 
| -            (dwPermissions&FPDFPERM_ANNOT_FORM);
 | 
| -        }
 | 
| -    }
 | 
| +    if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON)
 | 
| +        return TRUE;
 | 
|  
 | 
| -    return FALSE;
 | 
| +    CPDF_Page* pPage = pWidget->GetPDFPage();
 | 
| +    CPDF_Document* pDocument = pPage->m_pDocument;
 | 
| +    FX_DWORD dwPermissions = pDocument->GetUserPermissions();
 | 
| +    return (dwPermissions & FPDFPERM_FILL_FORM) ||
 | 
| +            (dwPermissions & FPDFPERM_ANNOT_FORM);
 | 
|  }
 | 
|  
 | 
|  CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage)
 | 
| @@ -1338,12 +1308,11 @@ void CPDFSDK_AnnotIterator::InsertSort(CFX_PtrArray &arrayList, AI_COMPARE pComp
 | 
|  
 | 
|  int LyOrderCompare(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2)
 | 
|  {
 | 
| -    if(p1->GetLayoutOrder() < p2->GetLayoutOrder())
 | 
| +    if (p1->GetLayoutOrder() < p2->GetLayoutOrder())
 | 
|          return -1;
 | 
| -    else if (p1->GetLayoutOrder() == p2->GetLayoutOrder())
 | 
| -        return 0;
 | 
| -    else
 | 
| +    if (p1->GetLayoutOrder() > p2->GetLayoutOrder())
 | 
|          return 1;
 | 
| +    return 0;
 | 
|  }
 | 
|  
 | 
|  FX_BOOL CPDFSDK_AnnotIterator::InitIteratorAnnotList(CPDFSDK_PageView* pPageView,CFX_PtrArray * pAnnotList)
 | 
| 
 |