summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-11-07 20:06:01 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-07 20:06:01 +0000
commitb415ffb47de6e58603db2a01027aa879c0126b24 (patch)
tree48117c166ada6f156d501de7da71d191fdce271a /xfa/fxfa
parentc0c3b8cb21296f182da3be97acf175346bc06004 (diff)
downloadpdfium-b415ffb47de6e58603db2a01027aa879c0126b24.tar.xz
Rename CXFA_Edge to CXFA_EdgeData
This CL renames CXFA_Edge to CXFA_EdgeData to make it clear it's part of the data hierarchy. Change-Id: Id67526cafe1927803c36159b106656c32e770d6b Reviewed-on: https://pdfium-review.googlesource.com/17979 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/cxfa_ffline.cpp14
-rw-r--r--xfa/fxfa/cxfa_ffpushbutton.cpp7
-rw-r--r--xfa/fxfa/cxfa_ffwidget.cpp54
-rw-r--r--xfa/fxfa/parser/cxfa_boxdata.cpp16
-rw-r--r--xfa/fxfa/parser/cxfa_boxdata.h4
-rw-r--r--xfa/fxfa/parser/cxfa_edgedata.h (renamed from xfa/fxfa/parser/cxfa_edge.h)10
-rw-r--r--xfa/fxfa/parser/cxfa_line.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_line.h4
8 files changed, 53 insertions, 60 deletions
diff --git a/xfa/fxfa/cxfa_ffline.cpp b/xfa/fxfa/cxfa_ffline.cpp
index 358b8c3714..cc52ce1763 100644
--- a/xfa/fxfa/cxfa_ffline.cpp
+++ b/xfa/fxfa/cxfa_ffline.cpp
@@ -62,15 +62,15 @@ void CXFA_FFLine::RenderWidget(CXFA_Graphics* pGS,
int32_t iStrokeType = 0;
float fLineWidth = 1.0f;
int32_t iCap = 0;
- CXFA_Edge edge = lineObj.GetEdge();
- if (edge) {
- if (edge.GetPresence() != XFA_ATTRIBUTEENUM_Visible)
+ CXFA_EdgeData edgeData = lineObj.GetEdgeData();
+ if (edgeData) {
+ if (edgeData.GetPresence() != XFA_ATTRIBUTEENUM_Visible)
return;
- lineColor = edge.GetColor();
- iStrokeType = edge.GetStrokeType();
- fLineWidth = edge.GetThickness();
- iCap = edge.GetCapType();
+ lineColor = edgeData.GetColor();
+ iStrokeType = edgeData.GetStrokeType();
+ fLineWidth = edgeData.GetThickness();
+ iCap = edgeData.GetCapType();
}
CFX_Matrix mtRotate = GetRotateMatrix();
diff --git a/xfa/fxfa/cxfa_ffpushbutton.cpp b/xfa/fxfa/cxfa_ffpushbutton.cpp
index 9ec48b865d..54725ad794 100644
--- a/xfa/fxfa/cxfa_ffpushbutton.cpp
+++ b/xfa/fxfa/cxfa_ffpushbutton.cpp
@@ -114,10 +114,9 @@ bool CXFA_FFPushButton::PerformLayout() {
}
float CXFA_FFPushButton::GetLineWidth() {
CXFA_BorderData borderData = m_pDataAcc->GetBorderData(false);
- if (borderData && borderData.GetPresence() == XFA_ATTRIBUTEENUM_Visible) {
- CXFA_Edge edge = borderData.GetEdge(0);
- return edge.GetThickness();
- }
+ if (borderData && borderData.GetPresence() == XFA_ATTRIBUTEENUM_Visible)
+ return borderData.GetEdgeData(0).GetThickness();
+
return 0;
}
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index f6949c4853..dcacf5054d 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -7,6 +7,7 @@
#include "xfa/fxfa/cxfa_ffwidget.h"
#include <algorithm>
+#include <cmath>
#include <memory>
#include <vector>
@@ -85,24 +86,23 @@ void XFA_BOX_GetPath(const std::vector<CXFA_Stroke>& strokes,
float halfBefore = 0.0f;
CXFA_Stroke stroke = strokes[nIndex];
if (stroke.IsCorner()) {
- CXFA_Stroke edgeBefore = strokes[(nIndex + 1 * 8 - 1) % 8];
- CXFA_Stroke edgeAfter = strokes[nIndex + 1];
+ CXFA_Stroke strokeBefore = strokes[(nIndex + 1 * 8 - 1) % 8];
+ CXFA_Stroke strokeAfter = strokes[nIndex + 1];
if (stroke.IsInverted()) {
- if (!stroke.SameStyles(edgeBefore)) {
- halfBefore = edgeBefore.GetThickness() / 2;
- }
- if (!stroke.SameStyles(edgeAfter)) {
- halfAfter = edgeAfter.GetThickness() / 2;
- }
+ if (!stroke.SameStyles(strokeBefore))
+ halfBefore = strokeBefore.GetThickness() / 2;
+ if (!stroke.SameStyles(strokeAfter))
+ halfAfter = strokeAfter.GetThickness() / 2;
}
} else {
- CXFA_Stroke edgeBefore = strokes[(nIndex + 8 - 2) % 8];
- CXFA_Stroke edgeAfter = strokes[(nIndex + 2) % 8];
+ CXFA_Stroke strokeBefore = strokes[(nIndex + 8 - 2) % 8];
+ CXFA_Stroke strokeAfter = strokes[(nIndex + 2) % 8];
if (!bRound && !bInverted) {
- halfBefore = edgeBefore.GetThickness() / 2;
- halfAfter = edgeAfter.GetThickness() / 2;
+ halfBefore = strokeBefore.GetThickness() / 2;
+ halfAfter = strokeAfter.GetThickness() / 2;
}
}
+
float offsetEX = 0.0f;
float offsetEY = 0.0f;
float sx = 0.0f;
@@ -240,21 +240,18 @@ void XFA_BOX_GetFillPath(CXFA_BoxData boxData,
CXFA_Path& fillPath,
uint16_t dwFlags) {
if (boxData.IsArc() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) {
- CXFA_Edge edge = boxData.GetEdge(0);
- float fThickness = edge.GetThickness();
- if (fThickness < 0) {
- fThickness = 0;
- }
+ float fThickness = std::fmax(0.0, boxData.GetEdgeData(0).GetThickness());
float fHalf = fThickness / 2;
int32_t iHand = boxData.GetHand();
- if (iHand == XFA_ATTRIBUTEENUM_Left) {
+ if (iHand == XFA_ATTRIBUTEENUM_Left)
rtWidget.Inflate(fHalf, fHalf);
- } else if (iHand == XFA_ATTRIBUTEENUM_Right) {
+ else if (iHand == XFA_ATTRIBUTEENUM_Right)
rtWidget.Deflate(fHalf, fHalf);
- }
+
XFA_BOX_GetPath_Arc(boxData, rtWidget, fillPath, dwFlags);
return;
}
+
bool bSameStyles = true;
CXFA_Stroke stroke1 = strokes[0];
for (int32_t i = 1; i < 8; i++) {
@@ -556,10 +553,10 @@ void XFA_BOX_StrokeArc(CXFA_BoxData boxData,
CFX_RectF rtWidget,
const CFX_Matrix& matrix,
uint32_t dwFlags) {
- CXFA_Edge edge = boxData.GetEdge(0);
- if (!edge || !edge.IsVisible()) {
+ CXFA_EdgeData edgeData = boxData.GetEdgeData(0);
+ if (!edgeData || !edgeData.IsVisible())
return;
- }
+
bool bVisible = false;
float fThickness = 0;
int32_t i3DType = boxData.Get3DStyle(bVisible, fThickness);
@@ -568,7 +565,7 @@ void XFA_BOX_StrokeArc(CXFA_BoxData boxData,
dwFlags |= XFA_DRAWBOX_Lowered3D;
}
}
- float fHalf = edge.GetThickness() / 2;
+ float fHalf = edgeData.GetThickness() / 2;
if (fHalf < 0) {
fHalf = 0;
}
@@ -585,7 +582,7 @@ void XFA_BOX_StrokeArc(CXFA_BoxData boxData,
CXFA_Path arcPath;
XFA_BOX_GetPath_Arc(boxData, rtWidget, arcPath, dwFlags);
- XFA_BOX_StrokePath(edge, &arcPath, pGS, matrix);
+ XFA_BOX_StrokePath(edgeData, &arcPath, pGS, matrix);
return;
}
pGS->SaveGraphState();
@@ -832,11 +829,8 @@ void XFA_BOX_Stroke(CXFA_BoxData boxData,
return;
}
for (int32_t i = 1; i < 8; i += 2) {
- CXFA_Edge edge(strokes[i].GetNode());
- float fThickness = edge.GetThickness();
- if (fThickness < 0) {
- fThickness = 0;
- }
+ float fThickness =
+ std::fmax(0.0, CXFA_EdgeData(strokes[i].GetNode()).GetThickness());
float fHalf = fThickness / 2;
int32_t iHand = boxData.GetHand();
switch (i) {
diff --git a/xfa/fxfa/parser/cxfa_boxdata.cpp b/xfa/fxfa/parser/cxfa_boxdata.cpp
index 51fadffd79..607a1571dc 100644
--- a/xfa/fxfa/parser/cxfa_boxdata.cpp
+++ b/xfa/fxfa/parser/cxfa_boxdata.cpp
@@ -33,10 +33,10 @@ void GetStrokesInternal(CXFA_Node* pNode,
(*strokes)[j] = (*strokes)[2];
}
j++;
- CXFA_Edge edge =
- CXFA_Edge(pNode->JSNode()->GetProperty(i, XFA_Element::Edge, i == 0));
- if (edge || i == 0) {
- (*strokes)[j] = edge;
+ CXFA_EdgeData edgeData = CXFA_EdgeData(
+ pNode->JSNode()->GetProperty(i, XFA_Element::Edge, i == 0));
+ if (edgeData || i == 0) {
+ (*strokes)[j] = edgeData;
} else if (!bNull) {
if (i == 1 || i == 2)
(*strokes)[j] = (*strokes)[1];
@@ -93,10 +93,10 @@ int32_t CXFA_BoxData::CountEdges() const {
return m_pNode->CountChildren(XFA_Element::Edge, false);
}
-CXFA_Edge CXFA_BoxData::GetEdge(int32_t nIndex) const {
- return CXFA_Edge(m_pNode ? m_pNode->JSNode()->GetProperty(
- nIndex, XFA_Element::Edge, nIndex == 0)
- : nullptr);
+CXFA_EdgeData CXFA_BoxData::GetEdgeData(int32_t nIndex) const {
+ return CXFA_EdgeData(m_pNode ? m_pNode->JSNode()->GetProperty(
+ nIndex, XFA_Element::Edge, nIndex == 0)
+ : nullptr);
}
void CXFA_BoxData::GetStrokes(std::vector<CXFA_Stroke>* strokes) const {
diff --git a/xfa/fxfa/parser/cxfa_boxdata.h b/xfa/fxfa/parser/cxfa_boxdata.h
index b664479a28..384d4c1e00 100644
--- a/xfa/fxfa/parser/cxfa_boxdata.h
+++ b/xfa/fxfa/parser/cxfa_boxdata.h
@@ -11,7 +11,7 @@
#include "core/fxcrt/fx_system.h"
#include "xfa/fxfa/parser/cxfa_data.h"
-#include "xfa/fxfa/parser/cxfa_edge.h"
+#include "xfa/fxfa/parser/cxfa_edgedata.h"
#include "xfa/fxfa/parser/cxfa_fill.h"
#include "xfa/fxfa/parser/cxfa_margin.h"
@@ -29,7 +29,7 @@ class CXFA_BoxData : public CXFA_Data {
int32_t GetHand() const;
int32_t GetPresence() const;
int32_t CountEdges() const;
- CXFA_Edge GetEdge(int32_t nIndex = 0) const;
+ CXFA_EdgeData GetEdgeData(int32_t nIndex = 0) const;
void GetStrokes(std::vector<CXFA_Stroke>* strokes) const;
bool IsCircular() const;
bool GetStartAngle(float& fStartAngle) const;
diff --git a/xfa/fxfa/parser/cxfa_edge.h b/xfa/fxfa/parser/cxfa_edgedata.h
index 96e725f4c6..5e9ebf3db5 100644
--- a/xfa/fxfa/parser/cxfa_edge.h
+++ b/xfa/fxfa/parser/cxfa_edgedata.h
@@ -4,16 +4,16 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_FXFA_PARSER_CXFA_EDGE_H_
-#define XFA_FXFA_PARSER_CXFA_EDGE_H_
+#ifndef XFA_FXFA_PARSER_CXFA_EDGEDATA_H_
+#define XFA_FXFA_PARSER_CXFA_EDGEDATA_H_
#include "xfa/fxfa/parser/cxfa_stroke.h"
class CXFA_Node;
-class CXFA_Edge : public CXFA_Stroke {
+class CXFA_EdgeData : public CXFA_Stroke {
public:
- explicit CXFA_Edge(CXFA_Node* pNode) : CXFA_Stroke(pNode) {}
+ explicit CXFA_EdgeData(CXFA_Node* pNode) : CXFA_Stroke(pNode) {}
};
-#endif // XFA_FXFA_PARSER_CXFA_EDGE_H_
+#endif // XFA_FXFA_PARSER_CXFA_EDGEDATA_H_
diff --git a/xfa/fxfa/parser/cxfa_line.cpp b/xfa/fxfa/parser/cxfa_line.cpp
index 85f38a2822..5216bd4622 100644
--- a/xfa/fxfa/parser/cxfa_line.cpp
+++ b/xfa/fxfa/parser/cxfa_line.cpp
@@ -17,6 +17,6 @@ bool CXFA_Line::GetSlope() {
XFA_ATTRIBUTEENUM_Slash;
}
-CXFA_Edge CXFA_Line::GetEdge() {
- return CXFA_Edge(m_pNode->GetChild(0, XFA_Element::Edge, false));
+CXFA_EdgeData CXFA_Line::GetEdgeData() {
+ return CXFA_EdgeData(m_pNode->GetChild(0, XFA_Element::Edge, false));
}
diff --git a/xfa/fxfa/parser/cxfa_line.h b/xfa/fxfa/parser/cxfa_line.h
index f014cc0618..b167e39810 100644
--- a/xfa/fxfa/parser/cxfa_line.h
+++ b/xfa/fxfa/parser/cxfa_line.h
@@ -9,7 +9,7 @@
#include "core/fxcrt/fx_system.h"
#include "xfa/fxfa/parser/cxfa_data.h"
-#include "xfa/fxfa/parser/cxfa_edge.h"
+#include "xfa/fxfa/parser/cxfa_edgedata.h"
class CXFA_Node;
@@ -19,7 +19,7 @@ class CXFA_Line : public CXFA_Data {
int32_t GetHand();
bool GetSlope();
- CXFA_Edge GetEdge();
+ CXFA_EdgeData GetEdgeData();
};
#endif // XFA_FXFA_PARSER_CXFA_LINE_H_