Chromium Code Reviews| Index: xfa/fxfa/app/xfa_ffwidget.cpp |
| diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp |
| index 3af84a6bbe255fbb55c6dbf72c78da1aa39a5659..267e94e7c21d36f9c7bacf4a6a3cf188ff715877 100644 |
| --- a/xfa/fxfa/app/xfa_ffwidget.cpp |
| +++ b/xfa/fxfa/app/xfa_ffwidget.cpp |
| @@ -270,12 +270,12 @@ void CXFA_FFWidget::Rotate2Normal(FX_FLOAT& fx, FX_FLOAT& fy) { |
| } |
| static void XFA_GetMatrix(CFX_Matrix& m, |
|
Lei Zhang
2016/05/20 03:48:02
BTW, this only has 1 caller and |at| is always XFA
Wei Li
2016/05/20 16:33:15
Yes, I noticed that. I suspect there are some unfi
|
| int32_t iRotate, |
| - int32_t at, |
| + XFA_ATTRIBUTEENUM at, |
| const CFX_RectF& rt) { |
| if (!iRotate) { |
| return; |
| } |
| - FX_FLOAT fAnchorX, fAnchorY; |
| + FX_FLOAT fAnchorX = 0, fAnchorY = 0; |
|
Lei Zhang
2016/05/20 03:48:02
One per line please.
Wei Li
2016/05/20 16:33:14
Done.
|
| switch (at) { |
| case XFA_ATTRIBUTEENUM_TopLeft: |
| fAnchorX = rt.left, fAnchorY = rt.top; |
| @@ -305,6 +305,8 @@ static void XFA_GetMatrix(CFX_Matrix& m, |
| case XFA_ATTRIBUTEENUM_BottomRight: |
| fAnchorX = rt.right(), fAnchorY = rt.bottom(); |
| break; |
| + default: |
| + break; |
| } |
| switch (iRotate) { |
| case 90: |
| @@ -1157,20 +1159,24 @@ static void XFA_BOX_GetPath(CXFA_Box box, |
| FX_BOOL bStart, |
| FX_BOOL bCorner) { |
| ASSERT(nIndex >= 0 && nIndex < 8); |
| - FX_BOOL bInverted, bRound; |
| - FX_FLOAT fRadius1, fRadius2, sx, sy, vx, vy, nx, ny, offsetY, offsetX, |
| - offsetEX, offsetEY; |
| - CFX_PointF cpStart, cp, cp1, cp2; |
| - CFX_RectF rtRadius; |
| + FX_FLOAT sx = 0.0f; |
|
Lei Zhang
2016/05/20 03:48:02
Can you declare variables closer to where they are
Wei Li
2016/05/20 16:33:15
Done.
|
| + FX_FLOAT sy = 0.0f; |
| + FX_FLOAT vx = 1.0f; |
| + FX_FLOAT vy = 1.0f; |
| + FX_FLOAT nx = 1.0f; |
| + FX_FLOAT ny = 1.0f; |
| + CFX_PointF cpStart; |
| + CFX_PointF cp1; |
| + CFX_PointF cp2; |
| int32_t n = (nIndex & 1) ? nIndex - 1 : nIndex; |
| CXFA_Corner corner1(strokes[n].GetNode()); |
| CXFA_Corner corner2(strokes[(n + 2) % 8].GetNode()); |
| - fRadius1 = bCorner ? corner1.GetRadius() : 0; |
| - fRadius2 = bCorner ? corner2.GetRadius() : 0; |
| - bInverted = corner1.IsInverted(); |
| - offsetY = 0.0f; |
| - offsetX = 0.0f; |
| - bRound = corner1.GetJoinType() == XFA_ATTRIBUTEENUM_Round; |
| + FX_FLOAT fRadius1 = bCorner ? corner1.GetRadius() : 0.0f; |
| + FX_FLOAT fRadius2 = bCorner ? corner2.GetRadius() : 0.0f; |
| + FX_BOOL bInverted = corner1.IsInverted(); |
| + FX_FLOAT offsetY = 0.0f; |
| + FX_FLOAT offsetX = 0.0f; |
| + FX_BOOL bRound = corner1.GetJoinType() == XFA_ATTRIBUTEENUM_Round; |
| FX_FLOAT halfAfter = 0.0f; |
| FX_FLOAT halfBefore = 0.0f; |
| CXFA_Stroke stroke = strokes[nIndex]; |
| @@ -1193,8 +1199,8 @@ static void XFA_BOX_GetPath(CXFA_Box box, |
| { halfAfter = edgeAfter.GetThickness() / 2; } |
| } |
| } |
| - offsetEX = 0.0f; |
| - offsetEY = 0.0f; |
| + FX_FLOAT offsetEX = 0.0f; |
| + FX_FLOAT offsetEY = 0.0f; |
| if (bRound) { |
| sy = FX_PI / 2; |
| } |
| @@ -1291,6 +1297,7 @@ static void XFA_BOX_GetPath(CXFA_Box box, |
| if (bInverted) { |
| sy *= -1; |
| } |
| + CFX_RectF rtRadius; |
| rtRadius.Set(cp1.x + offsetX * 2, cp1.y + offsetY * 2, |
| fRadius1 * 2 * vx - offsetX * 2, |
| fRadius1 * 2 * vy - offsetY * 2); |
| @@ -1301,6 +1308,7 @@ static void XFA_BOX_GetPath(CXFA_Box box, |
| path.ArcTo(rtRadius.left, rtRadius.top, rtRadius.width, rtRadius.height, sx, |
| sy); |
| } else { |
| + CFX_PointF cp; |
| if (bInverted) { |
| cp.x = cp1.x + fRadius1 * vx, cp.y = cp1.y + fRadius1 * vy; |
| } else { |
| @@ -1369,17 +1377,21 @@ static void XFA_BOX_GetFillPath(CXFA_Box box, |
| rtWidget.height); |
| return; |
| } |
| - FX_BOOL bInverted, bRound; |
| - FX_FLOAT fRadius1, fRadius2, sx, sy, vx, vy, nx, ny; |
| - CFX_PointF cp, cp1, cp2; |
| - CFX_RectF rtRadius; |
| + |
| for (int32_t i = 0; i < 8; i += 2) { |
| + FX_FLOAT sx = 0.0f; |
| + FX_FLOAT sy = 0.0f; |
| + FX_FLOAT vx = 1.0f; |
| + FX_FLOAT vy = 1.0f; |
| + FX_FLOAT nx = 1.0f; |
| + FX_FLOAT ny = 1.0f; |
| + CFX_PointF cp1, cp2; |
| CXFA_Corner corner1(strokes[i].GetNode()); |
| CXFA_Corner corner2(strokes[(i + 2) % 8].GetNode()); |
| - fRadius1 = corner1.GetRadius(); |
| - fRadius2 = corner2.GetRadius(); |
| - bInverted = corner1.IsInverted(); |
| - bRound = corner1.GetJoinType() == XFA_ATTRIBUTEENUM_Round; |
| + FX_FLOAT fRadius1 = corner1.GetRadius(); |
| + FX_FLOAT fRadius2 = corner2.GetRadius(); |
| + FX_BOOL bInverted = corner1.IsInverted(); |
| + FX_BOOL bRound = corner1.GetJoinType() == XFA_ATTRIBUTEENUM_Round; |
| if (bRound) { |
| sy = FX_PI / 2; |
| } |
| @@ -1439,6 +1451,7 @@ static void XFA_BOX_GetFillPath(CXFA_Box box, |
| if (bInverted) { |
| sy *= -1; |
| } |
| + CFX_RectF rtRadius; |
| rtRadius.Set(cp1.x, cp1.y, fRadius1 * 2 * vx, fRadius1 * 2 * vy); |
| rtRadius.Normalize(); |
| if (bInverted) { |
| @@ -1447,6 +1460,7 @@ static void XFA_BOX_GetFillPath(CXFA_Box box, |
| fillPath.ArcTo(rtRadius.left, rtRadius.top, rtRadius.width, |
| rtRadius.height, sx, sy); |
| } else { |
| + CFX_PointF cp; |
| if (bInverted) { |
| cp.x = cp1.x + fRadius1 * vx, cp.y = cp1.y + fRadius1 * vy; |
| } else { |