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

Unified Diff: core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp

Issue 1419643005: Merge to XFA: Add type cast definitions for CPDF_Array. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 2 months 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 side-by-side diff with in-line comments
Download patch
Index: core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
index 3f915a7b7989200d204037458d0029ef62a539a2..a73bdc9e8ee182ecefd1e8d0f9d2da5190a50873 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
@@ -118,14 +118,11 @@ FX_BOOL CPDF_ShadingPattern::Load() {
}
CPDF_Object* pFunc = pShadingDict->GetElementValue(FX_BSTRC("Function"));
if (pFunc) {
- if (pFunc->GetType() == PDFOBJ_ARRAY) {
- m_nFuncs = ((CPDF_Array*)pFunc)->GetCount();
- if (m_nFuncs > 4) {
- m_nFuncs = 4;
- }
+ if (CPDF_Array* pArray = pFunc->AsArray()) {
+ m_nFuncs = std::min<int>(pArray->GetCount(), 4);
+
for (int i = 0; i < m_nFuncs; i++) {
- m_pFunctions[i] =
- CPDF_Function::Load(((CPDF_Array*)pFunc)->GetElementValue(i));
+ m_pFunctions[i] = CPDF_Function::Load(pArray->GetElementValue(i));
}
} else {
m_pFunctions[0] = CPDF_Function::Load(pFunc);

Powered by Google App Engine
This is Rietveld 408576698