summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-16 19:17:25 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-16 19:17:25 +0000
commit7824b6348e956d9310192515f8fce22c9f14d40e (patch)
tree353b465433f46998c53c4f6c77be1063cc6fc159 /xfa
parentdb269577f5f033c083d10b6327cbd1e1e32feb05 (diff)
downloadpdfium-7824b6348e956d9310192515f8fce22c9f14d40e.tar.xz
Rename flag to make usage clearer
The CXFA_FFWidget::DrawBorderWithFlags method only takes one flag to force rounded drawing. This CL renames the int32_t flags to a simple bool to make the usage clear. Change-Id: I4fb552dc77ce76e35225b15d15f2edbb7f5dcf01 Reviewed-on: https://pdfium-review.googlesource.com/23010 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxfa/cxfa_ffcheckbutton.cpp6
-rw-r--r--xfa/fxfa/cxfa_ffwidget.cpp59
-rw-r--r--xfa/fxfa/cxfa_ffwidget.h13
3 files changed, 36 insertions, 42 deletions
diff --git a/xfa/fxfa/cxfa_ffcheckbutton.cpp b/xfa/fxfa/cxfa_ffcheckbutton.cpp
index 69b5d6f943..89af82cdac 100644
--- a/xfa/fxfa/cxfa_ffcheckbutton.cpp
+++ b/xfa/fxfa/cxfa_ffcheckbutton.cpp
@@ -234,10 +234,8 @@ void CXFA_FFCheckButton::RenderWidget(CXFA_Graphics* pGS,
mtRotate.Concat(matrix);
CXFA_FFWidget::RenderWidget(pGS, mtRotate, dwStatus);
- DrawBorderWithFlags(
- pGS, m_pNode->GetWidgetAcc()->GetUIBorder(), m_rtUI, mtRotate,
- m_pNode->GetWidgetAcc()->IsCheckButtonRound() ? XFA_DRAWBOX_ForceRound
- : 0);
+ DrawBorderWithFlag(pGS, m_pNode->GetWidgetAcc()->GetUIBorder(), m_rtUI,
+ mtRotate, m_pNode->GetWidgetAcc()->IsCheckButtonRound());
RenderCaption(pGS, &mtRotate);
DrawHighlight(pGS, &mtRotate, dwStatus,
m_pNode->GetWidgetAcc()->IsCheckButtonRound());
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index 1024004158..2642980dd1 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -50,11 +50,11 @@ namespace {
void XFA_BOX_GetPath_Arc(CXFA_Box* box,
CFX_RectF rtDraw,
CXFA_GEPath& fillPath,
- uint32_t dwFlags) {
+ bool forceRound) {
float a, b;
a = rtDraw.width / 2.0f;
b = rtDraw.height / 2.0f;
- if (box->IsCircular() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0)
+ if (box->IsCircular() || forceRound)
a = b = std::min(a, b);
CFX_PointF center = rtDraw.Center();
@@ -248,8 +248,8 @@ void XFA_BOX_GetFillPath(CXFA_Box* box,
const std::vector<CXFA_Stroke*>& strokes,
CFX_RectF rtWidget,
CXFA_GEPath& fillPath,
- uint16_t dwFlags) {
- if (box->IsArc() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) {
+ bool forceRound) {
+ if (box->IsArc() || forceRound) {
CXFA_Edge* edge = box->GetEdgeIfExists(0);
float fThickness = std::fmax(0.0, edge ? edge->GetThickness() : 0);
float fHalf = fThickness / 2;
@@ -259,7 +259,7 @@ void XFA_BOX_GetFillPath(CXFA_Box* box,
else if (iHand == XFA_AttributeEnum::Right)
rtWidget.Deflate(fHalf, fHalf);
- XFA_BOX_GetPath_Arc(box, rtWidget, fillPath, dwFlags);
+ XFA_BOX_GetPath_Arc(box, rtWidget, fillPath, forceRound);
return;
}
@@ -491,15 +491,14 @@ void XFA_BOX_Fill(CXFA_Box* box,
CXFA_Graphics* pGS,
const CFX_RectF& rtWidget,
const CFX_Matrix& matrix,
- uint32_t dwFlags) {
+ bool forceRound) {
CXFA_Fill* fill = box->GetFillIfExists();
if (!fill || !fill->IsVisible())
return;
pGS->SaveGraphState();
CXFA_GEPath fillPath;
- XFA_BOX_GetFillPath(box, strokes, rtWidget, fillPath,
- (dwFlags & XFA_DRAWBOX_ForceRound) != 0);
+ XFA_BOX_GetFillPath(box, strokes, rtWidget, fillPath, forceRound);
fillPath.Close();
XFA_Element eType = fill->GetFillType();
switch (eType) {
@@ -562,7 +561,7 @@ void XFA_BOX_StrokeArc(CXFA_Box* box,
CXFA_Graphics* pGS,
CFX_RectF rtWidget,
const CFX_Matrix& matrix,
- uint32_t dwFlags) {
+ bool forceRound) {
CXFA_Edge* edge = box->GetEdgeIfExists(0);
if (!edge || !edge->IsVisible())
return;
@@ -571,11 +570,12 @@ void XFA_BOX_StrokeArc(CXFA_Box* box,
float fThickness;
XFA_AttributeEnum i3DType;
std::tie(i3DType, bVisible, fThickness) = box->Get3DStyle();
+ bool lowered3d = false;
if (i3DType != XFA_AttributeEnum::Unknown) {
- if (bVisible && fThickness >= 0.001f) {
- dwFlags |= XFA_DRAWBOX_Lowered3D;
- }
+ if (bVisible && fThickness >= 0.001f)
+ lowered3d = true;
}
+
float fHalf = edge->GetThickness() / 2;
if (fHalf < 0) {
fHalf = 0;
@@ -587,13 +587,12 @@ void XFA_BOX_StrokeArc(CXFA_Box* box,
} else if (iHand == XFA_AttributeEnum::Right) {
rtWidget.Deflate(fHalf, fHalf);
}
- if ((dwFlags & XFA_DRAWBOX_ForceRound) == 0 ||
- (dwFlags & XFA_DRAWBOX_Lowered3D) == 0) {
+ if (!forceRound || !lowered3d) {
if (fHalf < 0.001f)
return;
CXFA_GEPath arcPath;
- XFA_BOX_GetPath_Arc(box, rtWidget, arcPath, dwFlags);
+ XFA_BOX_GetPath_Arc(box, rtWidget, arcPath, forceRound);
XFA_BOX_StrokePath(edge, &arcPath, pGS, matrix);
return;
}
@@ -603,7 +602,7 @@ void XFA_BOX_StrokeArc(CXFA_Box* box,
float a, b;
a = rtWidget.width / 2.0f;
b = rtWidget.height / 2.0f;
- if (dwFlags & XFA_DRAWBOX_ForceRound) {
+ if (forceRound) {
a = std::min(a, b);
b = a;
}
@@ -829,9 +828,9 @@ void XFA_BOX_Stroke(CXFA_Box* box,
CXFA_Graphics* pGS,
CFX_RectF rtWidget,
const CFX_Matrix& matrix,
- uint32_t dwFlags) {
- if (box->IsArc() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) {
- XFA_BOX_StrokeArc(box, pGS, rtWidget, matrix, dwFlags);
+ bool forceRound) {
+ if (box->IsArc() || forceRound) {
+ XFA_BOX_StrokeArc(box, pGS, rtWidget, matrix, forceRound);
return;
}
@@ -891,7 +890,7 @@ void XFA_DrawBox(CXFA_Box* box,
CXFA_Graphics* pGS,
const CFX_RectF& rtWidget,
const CFX_Matrix& matrix,
- uint32_t dwFlags) {
+ bool forceRound) {
if (!box || box->GetPresence() != XFA_AttributeEnum::Visible)
return;
@@ -901,11 +900,11 @@ void XFA_DrawBox(CXFA_Box* box,
return;
}
std::vector<CXFA_Stroke*> strokes;
- if (!(dwFlags & XFA_DRAWBOX_ForceRound) && eType != XFA_Element::Arc)
+ if (!forceRound && eType != XFA_Element::Arc)
strokes = box->GetStrokes();
- XFA_BOX_Fill(box, strokes, pGS, rtWidget, matrix, dwFlags);
- XFA_BOX_Stroke(box, strokes, pGS, rtWidget, matrix, dwFlags);
+ XFA_BOX_Fill(box, strokes, pGS, rtWidget, matrix, forceRound);
+ XFA_BOX_Stroke(box, strokes, pGS, rtWidget, matrix, forceRound);
}
bool IsFXCodecErrorStatus(FXCODEC_STATUS status) {
@@ -1025,15 +1024,15 @@ void CXFA_FFWidget::DrawBorder(CXFA_Graphics* pGS,
CXFA_Box* box,
const CFX_RectF& rtBorder,
const CFX_Matrix& matrix) {
- XFA_DrawBox(box, pGS, rtBorder, matrix, 0);
+ XFA_DrawBox(box, pGS, rtBorder, matrix, false);
}
-void CXFA_FFWidget::DrawBorderWithFlags(CXFA_Graphics* pGS,
- CXFA_Box* box,
- const CFX_RectF& rtBorder,
- const CFX_Matrix& matrix,
- uint32_t dwFlags) {
- XFA_DrawBox(box, pGS, rtBorder, matrix, dwFlags);
+void CXFA_FFWidget::DrawBorderWithFlag(CXFA_Graphics* pGS,
+ CXFA_Box* box,
+ const CFX_RectF& rtBorder,
+ const CFX_Matrix& matrix,
+ bool forceRound) {
+ XFA_DrawBox(box, pGS, rtBorder, matrix, forceRound);
}
void CXFA_FFWidget::AddInvalidateRect() {
diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h
index 7c21903203..8ec92ef93f 100644
--- a/xfa/fxfa/cxfa_ffwidget.h
+++ b/xfa/fxfa/cxfa_ffwidget.h
@@ -71,9 +71,6 @@ void XFA_RectWithoutMargin(CFX_RectF& rt,
CXFA_FFWidget* XFA_GetWidgetFromLayoutItem(CXFA_LayoutItem* pLayoutItem);
bool XFA_IsCreateWidget(XFA_Element iType);
-#define XFA_DRAWBOX_ForceRound 1
-#define XFA_DRAWBOX_Lowered3D 2
-
class CXFA_CalcData {
public:
CXFA_CalcData();
@@ -172,11 +169,11 @@ class CXFA_FFWidget : public CXFA_ContentLayoutItem {
CXFA_Box* box,
const CFX_RectF& rtBorder,
const CFX_Matrix& matrix);
- void DrawBorderWithFlags(CXFA_Graphics* pGS,
- CXFA_Box* box,
- const CFX_RectF& rtBorder,
- const CFX_Matrix& matrix,
- uint32_t dwFlags);
+ void DrawBorderWithFlag(CXFA_Graphics* pGS,
+ CXFA_Box* box,
+ const CFX_RectF& rtBorder,
+ const CFX_Matrix& matrix,
+ bool forceRound);
CFX_RectF GetRectWithoutRotate();
bool IsMatchVisibleStatus(uint32_t dwStatus);