summaryrefslogtreecommitdiff
path: root/xfa/fxfa/app/xfa_fftext.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-02-09 09:17:20 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-02-09 15:04:51 +0000
commit1b08df18300bbc67dabd12fb35ab6ce1732a1024 (patch)
tree9773931c8d18709860c9fbc1177e290e7713044e /xfa/fxfa/app/xfa_fftext.cpp
parentac2e04797b258115b2dc768a56377d7e78038f42 (diff)
downloadpdfium-1b08df18300bbc67dabd12fb35ab6ce1732a1024.tar.xz
Convert Get methods to return instead of using out params.
This Cl changes several Get methods to return their values instead of using out parameters. Change-Id: Ie9a930a5c2d0e809f2d7181ca033d801945c1cf9 Reviewed-on: https://pdfium-review.googlesource.com/2556 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'xfa/fxfa/app/xfa_fftext.cpp')
-rw-r--r--xfa/fxfa/app/xfa_fftext.cpp117
1 files changed, 52 insertions, 65 deletions
diff --git a/xfa/fxfa/app/xfa_fftext.cpp b/xfa/fxfa/app/xfa_fftext.cpp
index 9176276d85..d8231bfda8 100644
--- a/xfa/fxfa/app/xfa_fftext.cpp
+++ b/xfa/fxfa/app/xfa_fftext.cpp
@@ -26,46 +26,48 @@ CXFA_FFText::~CXFA_FFText() {}
void CXFA_FFText::RenderWidget(CFX_Graphics* pGS,
CFX_Matrix* pMatrix,
uint32_t dwStatus) {
- if (!IsMatchVisibleStatus(dwStatus)) {
+ if (!IsMatchVisibleStatus(dwStatus))
+ return;
+
+ CFX_Matrix mtRotate = GetRotateMatrix();
+ if (pMatrix)
+ mtRotate.Concat(*pMatrix);
+
+ CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus);
+
+ CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout();
+ if (!pTextLayout)
return;
- }
- {
- CFX_Matrix mtRotate;
- GetRotateMatrix(mtRotate);
- if (pMatrix) {
- mtRotate.Concat(*pMatrix);
- }
- CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus);
- CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout();
- if (pTextLayout) {
- CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice();
- CFX_RectF rtText;
- GetRectWithoutRotate(rtText);
- if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) {
- CXFA_LayoutItem* pItem = this;
- if (!pItem->GetPrev() && !pItem->GetNext()) {
- XFA_RectWidthoutMargin(rtText, mgWidget);
- } else {
- FX_FLOAT fLeftInset, fRightInset, fTopInset = 0, fBottomInset = 0;
- mgWidget.GetLeftInset(fLeftInset);
- mgWidget.GetRightInset(fRightInset);
- if (!pItem->GetPrev()) {
- mgWidget.GetTopInset(fTopInset);
- } else if (!pItem->GetNext()) {
- mgWidget.GetBottomInset(fBottomInset);
- }
- rtText.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset);
- }
- }
- CFX_Matrix mt(1, 0, 0, 1, rtText.left, rtText.top);
- CFX_RectF rtClip = rtText;
- mtRotate.TransformRect(rtClip);
- mt.Concat(mtRotate);
- pTextLayout->DrawString(pRenderDevice, mt, rtClip, GetIndex());
+ CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice();
+ CFX_RectF rtText = GetRectWithoutRotate();
+ if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) {
+ CXFA_LayoutItem* pItem = this;
+ if (!pItem->GetPrev() && !pItem->GetNext()) {
+ XFA_RectWidthoutMargin(rtText, mgWidget);
+ } else {
+ FX_FLOAT fLeftInset;
+ FX_FLOAT fRightInset;
+ FX_FLOAT fTopInset = 0;
+ FX_FLOAT fBottomInset = 0;
+ mgWidget.GetLeftInset(fLeftInset);
+ mgWidget.GetRightInset(fRightInset);
+ if (!pItem->GetPrev())
+ mgWidget.GetTopInset(fTopInset);
+ else if (!pItem->GetNext())
+ mgWidget.GetBottomInset(fBottomInset);
+
+ rtText.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset);
}
}
+
+ CFX_Matrix mt(1, 0, 0, 1, rtText.left, rtText.top);
+ CFX_RectF rtClip = rtText;
+ mtRotate.TransformRect(rtClip);
+ mt.Concat(mtRotate);
+ pTextLayout->DrawString(pRenderDevice, mt, rtClip, GetIndex());
}
+
bool CXFA_FFText::IsLoaded() {
CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout();
return pTextLayout && !pTextLayout->m_bHasBlock;
@@ -104,31 +106,23 @@ bool CXFA_FFText::PerformLayout() {
pTextLayout->m_bHasBlock = false;
return true;
}
+
bool CXFA_FFText::OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) {
- CFX_RectF rtBox;
- GetRectWithoutRotate(rtBox);
- if (!rtBox.Contains(fx, fy)) {
+ if (!GetRectWithoutRotate().Contains(fx, fy))
return false;
- }
+
const FX_WCHAR* wsURLContent = GetLinkURLAtPoint(fx, fy);
- if (!wsURLContent) {
+ if (!wsURLContent)
return false;
- }
+
SetButtonDown(true);
return true;
}
+
bool CXFA_FFText::OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) {
- CFX_RectF rtBox;
- GetRectWithoutRotate(rtBox);
- if (!rtBox.Contains(fx, fy)) {
- return false;
- }
- const FX_WCHAR* wsURLContent = GetLinkURLAtPoint(fx, fy);
- if (!wsURLContent) {
- return false;
- }
- return true;
+ return GetRectWithoutRotate().Contains(fx, fy) && !!GetLinkURLAtPoint(fx, fy);
}
+
bool CXFA_FFText::OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) {
if (!IsButtonDown()) {
return false;
@@ -142,35 +136,28 @@ bool CXFA_FFText::OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) {
pDoc->GetDocEnvironment()->GotoURL(pDoc, wsURLContent);
return true;
}
+
FWL_WidgetHit CXFA_FFText::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) {
- CFX_RectF rtBox;
- GetRectWithoutRotate(rtBox);
- if (!rtBox.Contains(fx, fy))
+ if (!GetRectWithoutRotate().Contains(fx, fy))
return FWL_WidgetHit::Unknown;
if (!GetLinkURLAtPoint(fx, fy))
return FWL_WidgetHit::Unknown;
return FWL_WidgetHit::HyperLink;
}
+
const FX_WCHAR* CXFA_FFText::GetLinkURLAtPoint(FX_FLOAT fx, FX_FLOAT fy) {
CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout();
if (!pTextLayout)
return nullptr;
- FX_FLOAT x(fx);
- FX_FLOAT y(fy);
- FWLToClient(x, y);
-
+ CFX_RectF rect = GetRectWithoutRotate();
for (const auto& pPieceLine : *pTextLayout->GetPieceLines()) {
for (const auto& pPiece : pPieceLine->m_textPieces) {
- if (pPiece->pLinkData && pPiece->rtPiece.Contains(x, y))
+ if (pPiece->pLinkData &&
+ pPiece->rtPiece.Contains(fx - rect.left, fy - rect.top)) {
return pPiece->pLinkData->GetLinkURL();
+ }
}
}
return nullptr;
}
-void CXFA_FFText::FWLToClient(FX_FLOAT& fx, FX_FLOAT& fy) {
- CFX_RectF rtWidget;
- GetRectWithoutRotate(rtWidget);
- fx -= rtWidget.left;
- fy -= rtWidget.top;
-}