diff options
author | Lei Zhang <thestig@chromium.org> | 2017-05-04 14:10:50 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-05-04 21:25:26 +0000 |
commit | b8a8c43f394277d1f87320a4f01b4d5c38e81113 (patch) | |
tree | d7e0ffa2d9ed7aa9e31e506538aa450ecabed937 /core/fpdfapi/page/cpdf_textstate.cpp | |
parent | d74da7bb34abdae254df64ba2c0da7a581f6dae0 (diff) | |
download | pdfium-b8a8c43f394277d1f87320a4f01b4d5c38e81113.tar.xz |
CPDF_Document::GetPageData() normally does not return NULL.
Add a comment to clarify and remove some unneeded checks.
Change-Id: I8b0492548b245abc45e161085047c9f36d6c8e2b
Reviewed-on: https://pdfium-review.googlesource.com/4871
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi/page/cpdf_textstate.cpp')
-rw-r--r-- | core/fpdfapi/page/cpdf_textstate.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/core/fpdfapi/page/cpdf_textstate.cpp b/core/fpdfapi/page/cpdf_textstate.cpp index 6dbad55ba6..bd236a2f28 100644 --- a/core/fpdfapi/page/cpdf_textstate.cpp +++ b/core/fpdfapi/page/cpdf_textstate.cpp @@ -115,25 +115,16 @@ CPDF_TextState::TextData::TextData(const TextData& that) for (int i = 0; i < 4; ++i) m_CTM[i] = that.m_CTM[i]; - if (m_pDocument && m_pFont) { + if (m_pDocument && m_pFont) m_pFont = m_pDocument->GetPageData()->GetFont(m_pFont->GetFontDict()); - } } CPDF_TextState::TextData::~TextData() { - if (m_pDocument && m_pFont) { - CPDF_DocPageData* pPageData = m_pDocument->GetPageData(); - if (pPageData && !pPageData->IsForceClear()) - pPageData->ReleaseFont(m_pFont->GetFontDict()); - } + ReleaseFont(); } void CPDF_TextState::TextData::SetFont(CPDF_Font* pFont) { - CPDF_Document* pDoc = m_pDocument; - CPDF_DocPageData* pPageData = pDoc ? pDoc->GetPageData() : nullptr; - if (pPageData && m_pFont && !pPageData->IsForceClear()) - pPageData->ReleaseFont(m_pFont->GetFontDict()); - + ReleaseFont(); m_pDocument = pFont ? pFont->GetDocument() : nullptr; m_pFont = pFont; } @@ -154,6 +145,15 @@ float CPDF_TextState::TextData::GetShearAngle() const { return GetBaselineAngle() + atan2(m_Matrix[1], m_Matrix[3]); } +void CPDF_TextState::TextData::ReleaseFont() { + if (!m_pDocument || !m_pFont) + return; + + CPDF_DocPageData* pPageData = m_pDocument->GetPageData(); + if (pPageData && !pPageData->IsForceClear()) + pPageData->ReleaseFont(m_pFont->GetFontDict()); +} + bool SetTextRenderingModeFromInt(int iMode, TextRenderingMode* mode) { if (iMode < 0 || iMode > 7) return false; |