Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: fpdfsdk/src/fsdk_mgr.cpp

Issue 1540263003: Add ContainsKey() and ContainsValue() and use them where appropriate. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fxge/ge/fx_ge_fontmap.cpp ('k') | fpdfsdk/src/javascript/JS_Runtime.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "fpdfsdk/include/fsdk_mgr.h" 9 #include "fpdfsdk/include/fsdk_mgr.h"
10 10
11 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" 11 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h"
12 #include "fpdfsdk/include/fsdk_define.h" 12 #include "fpdfsdk/include/fsdk_define.h"
13 #include "fpdfsdk/include/javascript/IJavaScript.h" 13 #include "fpdfsdk/include/javascript/IJavaScript.h"
14 #include "public/fpdf_ext.h" 14 #include "public/fpdf_ext.h"
15 #include "third_party/base/nonstd_unique_ptr.h" 15 #include "third_party/base/nonstd_unique_ptr.h"
16 #include "third_party/base/stl_util.h"
16 17
17 #if _FX_OS_ == _FX_ANDROID_ 18 #if _FX_OS_ == _FX_ANDROID_
18 #include "time.h" 19 #include "time.h"
19 #else 20 #else
20 #include <ctime> 21 #include <ctime>
21 #endif 22 #endif
22 23
23 class CFX_SystemHandler : public IFX_SystemHandler { 24 class CFX_SystemHandler : public IFX_SystemHandler {
24 public: 25 public:
25 explicit CFX_SystemHandler(CPDFDoc_Environment* pEnv) 26 explicit CFX_SystemHandler(CPDFDoc_Environment* pEnv)
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 return pSDKAnnot; 683 return pSDKAnnot;
683 } 684 }
684 } 685 }
685 686
686 return nullptr; 687 return nullptr;
687 } 688 }
688 689
689 void CPDFSDK_PageView::KillFocusAnnotIfNeeded() { 690 void CPDFSDK_PageView::KillFocusAnnotIfNeeded() {
690 // if there is a focused annot on the page, we should kill the focus first. 691 // if there is a focused annot on the page, we should kill the focus first.
691 if (CPDFSDK_Annot* focusedAnnot = m_pSDKDoc->GetFocusAnnot()) { 692 if (CPDFSDK_Annot* focusedAnnot = m_pSDKDoc->GetFocusAnnot()) {
692 auto it = 693 if (pdfium::ContainsValue(m_fxAnnotArray, focusedAnnot))
693 std::find(m_fxAnnotArray.begin(), m_fxAnnotArray.end(), focusedAnnot);
694 if (it != m_fxAnnotArray.end())
695 KillFocusAnnot(); 694 KillFocusAnnot();
696 } 695 }
697 } 696 }
698 697
699 FX_BOOL CPDFSDK_PageView::Annot_HasAppearance(CPDF_Annot* pAnnot) { 698 FX_BOOL CPDFSDK_PageView::Annot_HasAppearance(CPDF_Annot* pAnnot) {
700 CPDF_Dictionary* pAnnotDic = pAnnot->GetAnnotDict(); 699 CPDF_Dictionary* pAnnotDic = pAnnot->GetAnnotDict();
701 if (pAnnotDic) 700 if (pAnnotDic)
702 return pAnnotDic->KeyExist("AS"); 701 return pAnnotDic->KeyExist("AS");
703 return FALSE; 702 return FALSE;
704 } 703 }
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 } 903 }
905 } 904 }
906 return -1; 905 return -1;
907 } 906 }
908 907
909 bool CPDFSDK_PageView::IsValidAnnot(const CPDF_Annot* p) const { 908 bool CPDFSDK_PageView::IsValidAnnot(const CPDF_Annot* p) const {
910 if (!p) 909 if (!p)
911 return false; 910 return false;
912 911
913 const auto& annots = m_pAnnotList->All(); 912 const auto& annots = m_pAnnotList->All();
914 return std::find(annots.begin(), annots.end(), p) != annots.end(); 913 return pdfium::ContainsValue(annots, p);
915 } 914 }
916 915
917 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { 916 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() {
918 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); 917 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot();
919 if (!pFocusAnnot) 918 if (!pFocusAnnot)
920 return nullptr; 919 return nullptr;
921 920
922 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { 921 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) {
923 if (pAnnot == pFocusAnnot) 922 if (pAnnot == pFocusAnnot)
924 return pAnnot; 923 return pAnnot;
925 } 924 }
926 return nullptr; 925 return nullptr;
927 } 926 }
OLDNEW
« no previous file with comments | « core/src/fxge/ge/fx_ge_fontmap.cpp ('k') | fpdfsdk/src/javascript/JS_Runtime.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698