diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2018-01-10 19:51:41 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-01-10 19:51:41 +0000 |
commit | 678b97f3fc747cc203c036c01d23fe790b230b85 (patch) | |
tree | 1669701f109d2b5575a6983a37245cd14cd7805a /fxjs/xfa/cjx_instancemanager.cpp | |
parent | 78d841011655b868486a45e0fe865a972742aa0c (diff) | |
download | pdfium-678b97f3fc747cc203c036c01d23fe790b230b85.tar.xz |
Rename GetOccur to GetOccurIfExists
This CL makes it explicit that GetOccurIfExists can return nullptr and
fixes up the call sites.
Change-Id: I542d0098aa316632239df7f1a5796b4ffe6ba202
Reviewed-on: https://pdfium-review.googlesource.com/22676
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fxjs/xfa/cjx_instancemanager.cpp')
-rw-r--r-- | fxjs/xfa/cjx_instancemanager.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/fxjs/xfa/cjx_instancemanager.cpp b/fxjs/xfa/cjx_instancemanager.cpp index f6aef37c16..a5e3295c9b 100644 --- a/fxjs/xfa/cjx_instancemanager.cpp +++ b/fxjs/xfa/cjx_instancemanager.cpp @@ -33,13 +33,14 @@ CJX_InstanceManager::CJX_InstanceManager(CXFA_InstanceManager* mgr) CJX_InstanceManager::~CJX_InstanceManager() {} int32_t CJX_InstanceManager::SetInstances(int32_t iDesired) { - CXFA_Occur* occur = GetXFANode()->GetOccur(); - if (iDesired < occur->GetMin()) { + CXFA_Occur* occur = GetXFANode()->GetOccurIfExists(); + int32_t iMin = occur ? occur->GetMin() : CXFA_Occur::kDefaultMin; + if (iDesired < iMin) { ThrowTooManyOccurancesException(L"min"); return 1; } - int32_t iMax = occur->GetMax(); + int32_t iMax = occur ? occur->GetMax() : CXFA_Occur::kDefaultMax; if (iMax >= 0 && iDesired > iMax) { ThrowTooManyOccurancesException(L"max"); return 2; @@ -153,7 +154,8 @@ CJS_Return CJX_InstanceManager::removeInstance( if (iIndex < 0 || iIndex >= iCount) return CJS_Return(JSGetStringFromID(JSMessage::kInvalidInputError)); - int32_t iMin = GetXFANode()->GetOccur()->GetMin(); + CXFA_Occur* occur = GetXFANode()->GetOccurIfExists(); + int32_t iMin = occur ? occur->GetMin() : CXFA_Occur::kDefaultMin; if (iCount - 1 < iMin) return CJS_Return(JSGetStringFromID(JSMessage::kTooManyOccurances)); @@ -199,7 +201,8 @@ CJS_Return CJX_InstanceManager::addInstance( fFlags = runtime->ToBoolean(params[0]); int32_t iCount = GetXFANode()->GetCount(); - int32_t iMax = GetXFANode()->GetOccur()->GetMax(); + CXFA_Occur* occur = GetXFANode()->GetOccurIfExists(); + int32_t iMax = occur ? occur->GetMax() : CXFA_Occur::kDefaultMax; if (iMax >= 0 && iCount >= iMax) return CJS_Return(JSGetStringFromID(JSMessage::kTooManyOccurances)); @@ -240,7 +243,8 @@ CJS_Return CJX_InstanceManager::insertInstance( if (iIndex < 0 || iIndex > iCount) return CJS_Return(JSGetStringFromID(JSMessage::kInvalidInputError)); - int32_t iMax = GetXFANode()->GetOccur()->GetMax(); + CXFA_Occur* occur = GetXFANode()->GetOccurIfExists(); + int32_t iMax = occur ? occur->GetMax() : CXFA_Occur::kDefaultMax; if (iMax >= 0 && iCount >= iMax) return CJS_Return(JSGetStringFromID(JSMessage::kInvalidInputError)); @@ -272,7 +276,8 @@ void CJX_InstanceManager::max(CFXJSE_Value* pValue, ThrowInvalidPropertyException(); return; } - pValue->SetInteger(GetXFANode()->GetOccur()->GetMax()); + CXFA_Occur* occur = GetXFANode()->GetOccurIfExists(); + pValue->SetInteger(occur ? occur->GetMax() : CXFA_Occur::kDefaultMax); } void CJX_InstanceManager::min(CFXJSE_Value* pValue, @@ -282,7 +287,8 @@ void CJX_InstanceManager::min(CFXJSE_Value* pValue, ThrowInvalidPropertyException(); return; } - pValue->SetInteger(GetXFANode()->GetOccur()->GetMin()); + CXFA_Occur* occur = GetXFANode()->GetOccurIfExists(); + pValue->SetInteger(occur ? occur->GetMin() : CXFA_Occur::kDefaultMin); } void CJX_InstanceManager::count(CFXJSE_Value* pValue, |