summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-05-18 15:51:20 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-05-19 01:39:40 +0000
commit76020fc9751e55661d1c01b6cd92dfcb1fd56e6a (patch)
tree59d5251b23f5acb78891bf2911a79f2c70812c1c /xfa
parent22644731e0e46eae1f50927376e557c7d64db1d5 (diff)
downloadpdfium-76020fc9751e55661d1c01b6cd92dfcb1fd56e6a.tar.xz
Move CCodec_ModuleMgr ownership to CPDF_ModuleMgr.
More straight forward than CFX_GEModule owning in and CPDF_ModuleMgr holding a pointer to it. Remove assumptions that the codec modules may return nullptr, and do IWYU. Change-Id: Iba7fc3c7ec223fd6d29a1ab74ed13d35689bc5d5 Reviewed-on: https://pdfium-review.googlesource.com/5654 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r--xfa/DEPS4
-rw-r--r--xfa/fde/cfde_renderdevice.cpp1
-rw-r--r--xfa/fgas/layout/cfx_rtfbreak_unittest.cpp1
-rw-r--r--xfa/fxfa/DEPS5
-rw-r--r--xfa/fxfa/app/DEPS3
-rw-r--r--xfa/fxfa/cxfa_ffwidget.cpp53
-rw-r--r--xfa/fxfa/parser/cxfa_localemgr.cpp20
-rw-r--r--xfa/fxgraphics/cfx_graphics.cpp1
8 files changed, 33 insertions, 55 deletions
diff --git a/xfa/DEPS b/xfa/DEPS
index cc3061d2bc..2dd4ef3f54 100644
--- a/xfa/DEPS
+++ b/xfa/DEPS
@@ -1,7 +1,5 @@
include_rules = [
- '+core/fpdfapi/parser',
- '+core/fxcrt',
- '+core/fxge',
+ '+core',
'+fxbarcode',
'+third_party/bigint'
]
diff --git a/xfa/fde/cfde_renderdevice.cpp b/xfa/fde/cfde_renderdevice.cpp
index 9236dc7800..ec1fc2fed1 100644
--- a/xfa/fde/cfde_renderdevice.cpp
+++ b/xfa/fde/cfde_renderdevice.cpp
@@ -10,7 +10,6 @@
#include <memory>
#include <utility>
-#include "core/fxge/cfx_gemodule.h"
#include "core/fxge/cfx_graphstatedata.h"
#include "core/fxge/cfx_renderdevice.h"
#include "core/fxge/cfx_substfont.h"
diff --git a/xfa/fgas/layout/cfx_rtfbreak_unittest.cpp b/xfa/fgas/layout/cfx_rtfbreak_unittest.cpp
index c8ffc4eb33..cef215fe2a 100644
--- a/xfa/fgas/layout/cfx_rtfbreak_unittest.cpp
+++ b/xfa/fgas/layout/cfx_rtfbreak_unittest.cpp
@@ -8,6 +8,7 @@
#include <memory>
+#include "core/fxge/cfx_gemodule.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/test_support.h"
#include "third_party/base/ptr_util.h"
diff --git a/xfa/fxfa/DEPS b/xfa/fxfa/DEPS
index 97e9f52afa..886ee8e2b7 100644
--- a/xfa/fxfa/DEPS
+++ b/xfa/fxfa/DEPS
@@ -1,8 +1,3 @@
include_rules = [
- '+core/fdrm/crypto',
- '+core/fpdfapi/font',
- '+core/fpdfapi/page',
- '+core/fpdfdoc',
- '+core/fxcodec',
'+fxjs',
]
diff --git a/xfa/fxfa/app/DEPS b/xfa/fxfa/app/DEPS
deleted file mode 100644
index f722184c91..0000000000
--- a/xfa/fxfa/app/DEPS
+++ /dev/null
@@ -1,3 +0,0 @@
-include_rules = [
- '+core/fdrm/crypto',
-]
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index 7bbb8c8265..2ea30b59e5 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -10,12 +10,12 @@
#include <memory>
#include <vector>
+#include "core/fpdfapi/cpdf_modulemgr.h"
#include "core/fpdfapi/page/cpdf_pageobjectholder.h"
#include "core/fxcodec/codec/ccodec_progressivedecoder.h"
#include "core/fxcodec/fx_codec.h"
#include "core/fxcrt/cfx_maybe_owned.h"
#include "core/fxcrt/cfx_memorystream.h"
-#include "core/fxge/cfx_gemodule.h"
#include "core/fxge/cfx_pathdata.h"
#include "core/fxge/cfx_renderdevice.h"
#include "core/fxge/dib/cfx_imagerenderer.h"
@@ -1120,18 +1120,11 @@ CFX_RetainPtr<CFX_DIBitmap> XFA_LoadImageFromBuffer(
FXCODEC_IMAGE_TYPE type,
int32_t& iImageXDpi,
int32_t& iImageYDpi) {
- CFX_GEModule* pGeModule = CFX_GEModule::Get();
- if (!pGeModule)
- return nullptr;
-
- CCodec_ModuleMgr* pCodecMgr = pGeModule->GetCodecModule();
- if (!pCodecMgr)
- return nullptr;
-
- CFX_DIBAttribute dibAttr;
- CFX_RetainPtr<CFX_DIBitmap> pBitmap;
+ CCodec_ModuleMgr* pCodecMgr = CPDF_ModuleMgr::Get()->GetCodecModule();
std::unique_ptr<CCodec_ProgressiveDecoder> pProgressiveDecoder =
pCodecMgr->CreateProgressiveDecoder();
+
+ CFX_DIBAttribute dibAttr;
pProgressiveDecoder->LoadImageInfo(pImageFileRead, type, &dibAttr, false);
switch (dibAttr.m_wDPIUnit) {
case FXCODEC_RESUNIT_CENTIMETER:
@@ -1147,24 +1140,26 @@ CFX_RetainPtr<CFX_DIBitmap> XFA_LoadImageFromBuffer(
}
iImageXDpi = dibAttr.m_nXDPI > 1 ? dibAttr.m_nXDPI : (96);
iImageYDpi = dibAttr.m_nYDPI > 1 ? dibAttr.m_nYDPI : (96);
- if (pProgressiveDecoder->GetWidth() > 0 &&
- pProgressiveDecoder->GetHeight() > 0) {
- type = pProgressiveDecoder->GetType();
- int32_t iComponents = pProgressiveDecoder->GetNumComponents();
- int32_t iBpc = pProgressiveDecoder->GetBPC();
- FXDIB_Format dibFormat = XFA_GetDIBFormat(type, iComponents, iBpc);
- pBitmap = pdfium::MakeRetain<CFX_DIBitmap>();
- pBitmap->Create(pProgressiveDecoder->GetWidth(),
- pProgressiveDecoder->GetHeight(), dibFormat);
- pBitmap->Clear(0xffffffff);
- int32_t nFrames;
- if ((pProgressiveDecoder->GetFrames(nFrames) ==
- FXCODEC_STATUS_DECODE_READY) &&
- (nFrames > 0)) {
- pProgressiveDecoder->StartDecode(pBitmap, 0, 0, pBitmap->GetWidth(),
- pBitmap->GetHeight());
- pProgressiveDecoder->ContinueDecode();
- }
+ if (pProgressiveDecoder->GetWidth() <= 0 ||
+ pProgressiveDecoder->GetHeight() <= 0) {
+ return nullptr;
+ }
+
+ type = pProgressiveDecoder->GetType();
+ int32_t iComponents = pProgressiveDecoder->GetNumComponents();
+ int32_t iBpc = pProgressiveDecoder->GetBPC();
+ FXDIB_Format dibFormat = XFA_GetDIBFormat(type, iComponents, iBpc);
+ CFX_RetainPtr<CFX_DIBitmap> pBitmap = pdfium::MakeRetain<CFX_DIBitmap>();
+ pBitmap->Create(pProgressiveDecoder->GetWidth(),
+ pProgressiveDecoder->GetHeight(), dibFormat);
+ pBitmap->Clear(0xffffffff);
+ int32_t nFrames;
+ if ((pProgressiveDecoder->GetFrames(nFrames) ==
+ FXCODEC_STATUS_DECODE_READY) &&
+ (nFrames > 0)) {
+ pProgressiveDecoder->StartDecode(pBitmap, 0, 0, pBitmap->GetWidth(),
+ pBitmap->GetHeight());
+ pProgressiveDecoder->ContinueDecode();
}
return pBitmap;
}
diff --git a/xfa/fxfa/parser/cxfa_localemgr.cpp b/xfa/fxfa/parser/cxfa_localemgr.cpp
index 0a691a6ceb..fbb12e2b48 100644
--- a/xfa/fxfa/parser/cxfa_localemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_localemgr.cpp
@@ -11,9 +11,9 @@
#include <memory>
#include <utility>
+#include "core/fpdfapi/cpdf_modulemgr.h"
#include "core/fxcodec/fx_codec.h"
#include "core/fxcrt/xml/cxml_element.h"
-#include "core/fxge/cfx_gemodule.h"
#include "third_party/base/ptr_util.h"
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_nodelocale.h"
@@ -1056,23 +1056,17 @@ static std::unique_ptr<IFX_Locale> XFA_GetLocaleFromBuffer(const uint8_t* pBuf,
int nBufLen) {
if (!pBuf || nBufLen <= 0)
return nullptr;
- CFX_GEModule* pGeModule = CFX_GEModule::Get();
- if (!pGeModule)
- return nullptr;
-
- CCodec_ModuleMgr* pCodecMgr = pGeModule->GetCodecModule();
- if (!pCodecMgr)
- return nullptr;
- std::unique_ptr<CXML_Element> pLocale;
uint8_t* pOut = nullptr;
uint32_t dwSize;
+ CCodec_ModuleMgr* pCodecMgr = CPDF_ModuleMgr::Get()->GetCodecModule();
pCodecMgr->GetFlateModule()->FlateOrLZWDecode(false, pBuf, nBufLen, true, 0,
0, 0, 0, 0, pOut, dwSize);
- if (pOut) {
- pLocale = CXML_Element::Parse(pOut, dwSize);
- FX_Free(pOut);
- }
+ if (!pOut)
+ return nullptr;
+
+ std::unique_ptr<CXML_Element> pLocale = CXML_Element::Parse(pOut, dwSize);
+ FX_Free(pOut);
return pLocale ? pdfium::MakeUnique<CXFA_XMLLocale>(std::move(pLocale))
: nullptr;
}
diff --git a/xfa/fxgraphics/cfx_graphics.cpp b/xfa/fxgraphics/cfx_graphics.cpp
index 79e4b7a6cc..a67932f052 100644
--- a/xfa/fxgraphics/cfx_graphics.cpp
+++ b/xfa/fxgraphics/cfx_graphics.cpp
@@ -9,7 +9,6 @@
#include <memory>
#include "core/fxge/cfx_defaultrenderdevice.h"
-#include "core/fxge/cfx_gemodule.h"
#include "core/fxge/cfx_renderdevice.h"
#include "core/fxge/cfx_unicodeencoding.h"
#include "third_party/base/ptr_util.h"