diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-11-07 20:06:01 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-11-07 20:06:01 +0000 |
commit | b415ffb47de6e58603db2a01027aa879c0126b24 (patch) | |
tree | 48117c166ada6f156d501de7da71d191fdce271a | |
parent | c0c3b8cb21296f182da3be97acf175346bc06004 (diff) | |
download | pdfium-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>
-rw-r--r-- | BUILD.gn | 2 | ||||
-rw-r--r-- | fxjs/cjx_node.cpp | 19 | ||||
-rw-r--r-- | xfa/fwl/theme/cfwl_edittp.cpp | 8 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffline.cpp | 14 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffpushbutton.cpp | 7 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffwidget.cpp | 54 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_boxdata.cpp | 16 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_boxdata.h | 4 | ||||
-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.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_line.h | 4 |
11 files changed, 66 insertions, 76 deletions
@@ -1818,7 +1818,7 @@ if (pdf_enable_xfa) { "xfa/fxfa/parser/cxfa_document.h", "xfa/fxfa/parser/cxfa_document_parser.cpp", "xfa/fxfa/parser/cxfa_document_parser.h", - "xfa/fxfa/parser/cxfa_edge.h", + "xfa/fxfa/parser/cxfa_edgedata.h", "xfa/fxfa/parser/cxfa_event.cpp", "xfa/fxfa/parser/cxfa_event.h", "xfa/fxfa/parser/cxfa_exdata.cpp", diff --git a/fxjs/cjx_node.cpp b/fxjs/cjx_node.cpp index 224d295755..c82a9f4912 100644 --- a/fxjs/cjx_node.cpp +++ b/fxjs/cjx_node.cpp @@ -1536,13 +1536,11 @@ void CJX_Node::Script_Som_BorderColor(CFXJSE_Value* pValue, int32_t b = 0; StrToRGB(pValue->ToWideString(), r, g, b); FX_ARGB rgb = ArgbEncode(100, r, g, b); - for (int32_t i = 0; i < iSize; ++i) { - CXFA_Edge edge = borderData.GetEdge(i); - edge.SetColor(rgb); - } + for (int32_t i = 0; i < iSize; ++i) + borderData.GetEdgeData(i).SetColor(rgb); + } else { - CXFA_Edge edge = borderData.GetEdge(0); - FX_ARGB color = edge.GetColor(); + FX_ARGB color = borderData.GetEdgeData(0).GetColor(); int32_t a; int32_t r; int32_t g; @@ -1567,14 +1565,13 @@ void CJX_Node::Script_Som_BorderWidth(CFXJSE_Value* pValue, if (bSetting) { wsThickness = pValue->ToWideString(); for (int32_t i = 0; i < iSize; ++i) { - CXFA_Edge edge = borderData.GetEdge(i); - CXFA_Measurement thickness(wsThickness.AsStringView()); - edge.SetMSThickness(thickness); + borderData.GetEdgeData(i).SetMSThickness( + CXFA_Measurement(wsThickness.AsStringView())); } } else { - CXFA_Edge edge = borderData.GetEdge(0); - CXFA_Measurement thickness = edge.GetMSThickness(); + CXFA_Measurement thickness = borderData.GetEdgeData(0).GetMSThickness(); thickness.ToString(&wsThickness); + pValue->SetString(wsThickness.UTF8Encode().AsStringView()); } } diff --git a/xfa/fwl/theme/cfwl_edittp.cpp b/xfa/fwl/theme/cfwl_edittp.cpp index c01d5c9158..9b8497a41e 100644 --- a/xfa/fwl/theme/cfwl_edittp.cpp +++ b/xfa/fwl/theme/cfwl_edittp.cpp @@ -25,10 +25,10 @@ void CFWL_EditTP::DrawBackground(CFWL_ThemeBackground* pParams) { FX_ARGB cr = 0xFF000000; float fWidth = 1.0f; if (borderUIData) { - CXFA_Edge edge = borderUIData.GetEdge(0); - if (edge) { - cr = edge.GetColor(); - fWidth = edge.GetThickness(); + CXFA_EdgeData edgeData = borderUIData.GetEdgeData(0); + if (edgeData) { + cr = edgeData.GetColor(); + fWidth = edgeData.GetThickness(); } } pParams->m_pGraphics->SetStrokeColor(CXFA_Color(cr)); 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_ |