Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: xfa/fxfa/app/xfa_ffwidget.cpp

Issue 1998873002: Clean up XFA code which causes warnings (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: address comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/app/xfa_ffnotify.cpp ('k') | xfa/fxfa/app/xfa_ffwidgetacc.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fxfa/include/xfa_ffwidget.h" 7 #include "xfa/fxfa/include/xfa_ffwidget.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 GetRotateMatrix(mt); 263 GetRotateMatrix(mt);
264 if (mt.IsIdentity()) { 264 if (mt.IsIdentity()) {
265 return; 265 return;
266 } 266 }
267 CFX_Matrix mtReverse; 267 CFX_Matrix mtReverse;
268 mtReverse.SetReverse(mt); 268 mtReverse.SetReverse(mt);
269 mtReverse.TransformPoint(fx, fy); 269 mtReverse.TransformPoint(fx, fy);
270 } 270 }
271 static void XFA_GetMatrix(CFX_Matrix& m, 271 static void XFA_GetMatrix(CFX_Matrix& m,
272 int32_t iRotate, 272 int32_t iRotate,
273 int32_t at, 273 XFA_ATTRIBUTEENUM at,
274 const CFX_RectF& rt) { 274 const CFX_RectF& rt) {
275 if (!iRotate) { 275 if (!iRotate) {
276 return; 276 return;
277 } 277 }
278 FX_FLOAT fAnchorX, fAnchorY; 278 FX_FLOAT fAnchorX = 0;
279 FX_FLOAT fAnchorY = 0;
279 switch (at) { 280 switch (at) {
280 case XFA_ATTRIBUTEENUM_TopLeft: 281 case XFA_ATTRIBUTEENUM_TopLeft:
281 fAnchorX = rt.left, fAnchorY = rt.top; 282 fAnchorX = rt.left, fAnchorY = rt.top;
282 break; 283 break;
283 case XFA_ATTRIBUTEENUM_TopCenter: 284 case XFA_ATTRIBUTEENUM_TopCenter:
284 fAnchorX = (rt.left + rt.right()) / 2, fAnchorY = rt.top; 285 fAnchorX = (rt.left + rt.right()) / 2, fAnchorY = rt.top;
285 break; 286 break;
286 case XFA_ATTRIBUTEENUM_TopRight: 287 case XFA_ATTRIBUTEENUM_TopRight:
287 fAnchorX = rt.right(), fAnchorY = rt.top; 288 fAnchorX = rt.right(), fAnchorY = rt.top;
288 break; 289 break;
289 case XFA_ATTRIBUTEENUM_MiddleLeft: 290 case XFA_ATTRIBUTEENUM_MiddleLeft:
290 fAnchorX = rt.left, fAnchorY = (rt.top + rt.bottom()) / 2; 291 fAnchorX = rt.left, fAnchorY = (rt.top + rt.bottom()) / 2;
291 break; 292 break;
292 case XFA_ATTRIBUTEENUM_MiddleCenter: 293 case XFA_ATTRIBUTEENUM_MiddleCenter:
293 fAnchorX = (rt.left + rt.right()) / 2, 294 fAnchorX = (rt.left + rt.right()) / 2,
294 fAnchorY = (rt.top + rt.bottom()) / 2; 295 fAnchorY = (rt.top + rt.bottom()) / 2;
295 break; 296 break;
296 case XFA_ATTRIBUTEENUM_MiddleRight: 297 case XFA_ATTRIBUTEENUM_MiddleRight:
297 fAnchorX = rt.right(), fAnchorY = (rt.top + rt.bottom()) / 2; 298 fAnchorX = rt.right(), fAnchorY = (rt.top + rt.bottom()) / 2;
298 break; 299 break;
299 case XFA_ATTRIBUTEENUM_BottomLeft: 300 case XFA_ATTRIBUTEENUM_BottomLeft:
300 fAnchorX = rt.left, fAnchorY = rt.bottom(); 301 fAnchorX = rt.left, fAnchorY = rt.bottom();
301 break; 302 break;
302 case XFA_ATTRIBUTEENUM_BottomCenter: 303 case XFA_ATTRIBUTEENUM_BottomCenter:
303 fAnchorX = (rt.left + rt.right()) / 2, fAnchorY = rt.bottom(); 304 fAnchorX = (rt.left + rt.right()) / 2, fAnchorY = rt.bottom();
304 break; 305 break;
305 case XFA_ATTRIBUTEENUM_BottomRight: 306 case XFA_ATTRIBUTEENUM_BottomRight:
306 fAnchorX = rt.right(), fAnchorY = rt.bottom(); 307 fAnchorX = rt.right(), fAnchorY = rt.bottom();
307 break; 308 break;
309 default:
310 break;
308 } 311 }
309 switch (iRotate) { 312 switch (iRotate) {
310 case 90: 313 case 90:
311 m.a = 0, m.b = -1, m.c = 1, m.d = 0, m.e = fAnchorX - fAnchorY, 314 m.a = 0, m.b = -1, m.c = 1, m.d = 0, m.e = fAnchorX - fAnchorY,
312 m.f = fAnchorX + fAnchorY; 315 m.f = fAnchorX + fAnchorY;
313 break; 316 break;
314 case 180: 317 case 180:
315 m.a = -1, m.b = 0, m.c = 0, m.d = -1, m.e = fAnchorX * 2, 318 m.a = -1, m.b = 0, m.c = 0, m.d = -1, m.e = fAnchorX * 2,
316 m.f = fAnchorY * 2; 319 m.f = fAnchorY * 2;
317 break; 320 break;
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 startAngle, sweepAngle); 1153 startAngle, sweepAngle);
1151 } 1154 }
1152 static void XFA_BOX_GetPath(CXFA_Box box, 1155 static void XFA_BOX_GetPath(CXFA_Box box,
1153 const CXFA_StrokeArray& strokes, 1156 const CXFA_StrokeArray& strokes,
1154 CFX_RectF rtWidget, 1157 CFX_RectF rtWidget,
1155 CFX_Path& path, 1158 CFX_Path& path,
1156 int32_t nIndex, 1159 int32_t nIndex,
1157 FX_BOOL bStart, 1160 FX_BOOL bStart,
1158 FX_BOOL bCorner) { 1161 FX_BOOL bCorner) {
1159 ASSERT(nIndex >= 0 && nIndex < 8); 1162 ASSERT(nIndex >= 0 && nIndex < 8);
1160 FX_BOOL bInverted, bRound;
1161 FX_FLOAT fRadius1, fRadius2, sx, sy, vx, vy, nx, ny, offsetY, offsetX,
1162 offsetEX, offsetEY;
1163 CFX_PointF cpStart, cp, cp1, cp2;
1164 CFX_RectF rtRadius;
1165 int32_t n = (nIndex & 1) ? nIndex - 1 : nIndex; 1163 int32_t n = (nIndex & 1) ? nIndex - 1 : nIndex;
1166 CXFA_Corner corner1(strokes[n].GetNode()); 1164 CXFA_Corner corner1(strokes[n].GetNode());
1167 CXFA_Corner corner2(strokes[(n + 2) % 8].GetNode()); 1165 CXFA_Corner corner2(strokes[(n + 2) % 8].GetNode());
1168 fRadius1 = bCorner ? corner1.GetRadius() : 0; 1166 FX_FLOAT fRadius1 = bCorner ? corner1.GetRadius() : 0.0f;
1169 fRadius2 = bCorner ? corner2.GetRadius() : 0; 1167 FX_FLOAT fRadius2 = bCorner ? corner2.GetRadius() : 0.0f;
1170 bInverted = corner1.IsInverted(); 1168 FX_BOOL bInverted = corner1.IsInverted();
1171 offsetY = 0.0f; 1169 FX_FLOAT offsetY = 0.0f;
1172 offsetX = 0.0f; 1170 FX_FLOAT offsetX = 0.0f;
1173 bRound = corner1.GetJoinType() == XFA_ATTRIBUTEENUM_Round; 1171 FX_BOOL bRound = corner1.GetJoinType() == XFA_ATTRIBUTEENUM_Round;
1174 FX_FLOAT halfAfter = 0.0f; 1172 FX_FLOAT halfAfter = 0.0f;
1175 FX_FLOAT halfBefore = 0.0f; 1173 FX_FLOAT halfBefore = 0.0f;
1176 CXFA_Stroke stroke = strokes[nIndex]; 1174 CXFA_Stroke stroke = strokes[nIndex];
1177 if (stroke.IsCorner()) { 1175 if (stroke.IsCorner()) {
1178 CXFA_Stroke edgeBefore = strokes[(nIndex + 1 * 8 - 1) % 8]; 1176 CXFA_Stroke edgeBefore = strokes[(nIndex + 1 * 8 - 1) % 8];
1179 CXFA_Stroke edgeAfter = strokes[nIndex + 1]; 1177 CXFA_Stroke edgeAfter = strokes[nIndex + 1];
1180 if (stroke.IsInverted()) { 1178 if (stroke.IsInverted()) {
1181 if (!stroke.SameStyles(edgeBefore)) { 1179 if (!stroke.SameStyles(edgeBefore)) {
1182 halfBefore = edgeBefore.GetThickness() / 2; 1180 halfBefore = edgeBefore.GetThickness() / 2;
1183 } 1181 }
1184 if (!stroke.SameStyles(edgeAfter)) { 1182 if (!stroke.SameStyles(edgeAfter)) {
1185 halfAfter = edgeAfter.GetThickness() / 2; 1183 halfAfter = edgeAfter.GetThickness() / 2;
1186 } 1184 }
1187 } 1185 }
1188 } else { 1186 } else {
1189 CXFA_Stroke edgeBefore = strokes[(nIndex + 8 - 2) % 8]; 1187 CXFA_Stroke edgeBefore = strokes[(nIndex + 8 - 2) % 8];
1190 CXFA_Stroke edgeAfter = strokes[(nIndex + 2) % 8]; 1188 CXFA_Stroke edgeAfter = strokes[(nIndex + 2) % 8];
1191 if (!bRound && !bInverted) { 1189 if (!bRound && !bInverted) {
1192 { halfBefore = edgeBefore.GetThickness() / 2; } 1190 halfBefore = edgeBefore.GetThickness() / 2;
1193 { halfAfter = edgeAfter.GetThickness() / 2; } 1191 halfAfter = edgeAfter.GetThickness() / 2;
1194 } 1192 }
1195 } 1193 }
1196 offsetEX = 0.0f; 1194 FX_FLOAT offsetEX = 0.0f;
1197 offsetEY = 0.0f; 1195 FX_FLOAT offsetEY = 0.0f;
1196 FX_FLOAT sx = 0.0f;
1197 FX_FLOAT sy = 0.0f;
1198 FX_FLOAT vx = 1.0f;
1199 FX_FLOAT vy = 1.0f;
1200 FX_FLOAT nx = 1.0f;
1201 FX_FLOAT ny = 1.0f;
1202 CFX_PointF cpStart;
1203 CFX_PointF cp1;
1204 CFX_PointF cp2;
1198 if (bRound) { 1205 if (bRound) {
1199 sy = FX_PI / 2; 1206 sy = FX_PI / 2;
1200 } 1207 }
1201 switch (nIndex) { 1208 switch (nIndex) {
1202 case 0: 1209 case 0:
1203 case 1: 1210 case 1:
1204 cp1 = rtWidget.TopLeft(); 1211 cp1 = rtWidget.TopLeft();
1205 cp2 = rtWidget.TopRight(); 1212 cp2 = rtWidget.TopRight();
1206 if (nIndex == 0) { 1213 if (nIndex == 0) {
1207 cpStart.x = cp1.x - halfBefore; 1214 cpStart.x = cp1.x - halfBefore;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 cp2.y + fRadius2 * ny + offsetEY); 1291 cp2.y + fRadius2 * ny + offsetEY);
1285 return; 1292 return;
1286 } 1293 }
1287 if (bRound) { 1294 if (bRound) {
1288 if (fRadius1 < 0) { 1295 if (fRadius1 < 0) {
1289 sx -= FX_PI; 1296 sx -= FX_PI;
1290 } 1297 }
1291 if (bInverted) { 1298 if (bInverted) {
1292 sy *= -1; 1299 sy *= -1;
1293 } 1300 }
1301 CFX_RectF rtRadius;
1294 rtRadius.Set(cp1.x + offsetX * 2, cp1.y + offsetY * 2, 1302 rtRadius.Set(cp1.x + offsetX * 2, cp1.y + offsetY * 2,
1295 fRadius1 * 2 * vx - offsetX * 2, 1303 fRadius1 * 2 * vx - offsetX * 2,
1296 fRadius1 * 2 * vy - offsetY * 2); 1304 fRadius1 * 2 * vy - offsetY * 2);
1297 rtRadius.Normalize(); 1305 rtRadius.Normalize();
1298 if (bInverted) { 1306 if (bInverted) {
1299 rtRadius.Offset(-fRadius1 * vx, -fRadius1 * vy); 1307 rtRadius.Offset(-fRadius1 * vx, -fRadius1 * vy);
1300 } 1308 }
1301 path.ArcTo(rtRadius.left, rtRadius.top, rtRadius.width, rtRadius.height, sx, 1309 path.ArcTo(rtRadius.left, rtRadius.top, rtRadius.width, rtRadius.height, sx,
1302 sy); 1310 sy);
1303 } else { 1311 } else {
1312 CFX_PointF cp;
1304 if (bInverted) { 1313 if (bInverted) {
1305 cp.x = cp1.x + fRadius1 * vx, cp.y = cp1.y + fRadius1 * vy; 1314 cp.x = cp1.x + fRadius1 * vx, cp.y = cp1.y + fRadius1 * vy;
1306 } else { 1315 } else {
1307 cp = cp1; 1316 cp = cp1;
1308 } 1317 }
1309 path.LineTo(cp.x, cp.y); 1318 path.LineTo(cp.x, cp.y);
1310 path.LineTo(cp1.x + fRadius1 * sx + offsetX, 1319 path.LineTo(cp1.x + fRadius1 * sx + offsetX,
1311 cp1.y + fRadius1 * sy + offsetY); 1320 cp1.y + fRadius1 * sy + offsetY);
1312 } 1321 }
1313 } 1322 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1362 if (stroke1.GetJoinType() != XFA_ATTRIBUTEENUM_Square) { 1371 if (stroke1.GetJoinType() != XFA_ATTRIBUTEENUM_Square) {
1363 bSameStyles = FALSE; 1372 bSameStyles = FALSE;
1364 } 1373 }
1365 } 1374 }
1366 } 1375 }
1367 if (bSameStyles) { 1376 if (bSameStyles) {
1368 fillPath.AddRectangle(rtWidget.left, rtWidget.top, rtWidget.width, 1377 fillPath.AddRectangle(rtWidget.left, rtWidget.top, rtWidget.width,
1369 rtWidget.height); 1378 rtWidget.height);
1370 return; 1379 return;
1371 } 1380 }
1372 FX_BOOL bInverted, bRound; 1381
1373 FX_FLOAT fRadius1, fRadius2, sx, sy, vx, vy, nx, ny;
1374 CFX_PointF cp, cp1, cp2;
1375 CFX_RectF rtRadius;
1376 for (int32_t i = 0; i < 8; i += 2) { 1382 for (int32_t i = 0; i < 8; i += 2) {
1383 FX_FLOAT sx = 0.0f;
1384 FX_FLOAT sy = 0.0f;
1385 FX_FLOAT vx = 1.0f;
1386 FX_FLOAT vy = 1.0f;
1387 FX_FLOAT nx = 1.0f;
1388 FX_FLOAT ny = 1.0f;
1389 CFX_PointF cp1, cp2;
1377 CXFA_Corner corner1(strokes[i].GetNode()); 1390 CXFA_Corner corner1(strokes[i].GetNode());
1378 CXFA_Corner corner2(strokes[(i + 2) % 8].GetNode()); 1391 CXFA_Corner corner2(strokes[(i + 2) % 8].GetNode());
1379 fRadius1 = corner1.GetRadius(); 1392 FX_FLOAT fRadius1 = corner1.GetRadius();
1380 fRadius2 = corner2.GetRadius(); 1393 FX_FLOAT fRadius2 = corner2.GetRadius();
1381 bInverted = corner1.IsInverted(); 1394 FX_BOOL bInverted = corner1.IsInverted();
1382 bRound = corner1.GetJoinType() == XFA_ATTRIBUTEENUM_Round; 1395 FX_BOOL bRound = corner1.GetJoinType() == XFA_ATTRIBUTEENUM_Round;
1383 if (bRound) { 1396 if (bRound) {
1384 sy = FX_PI / 2; 1397 sy = FX_PI / 2;
1385 } 1398 }
1386 switch (i) { 1399 switch (i) {
1387 case 0: 1400 case 0:
1388 cp1 = rtWidget.TopLeft(); 1401 cp1 = rtWidget.TopLeft();
1389 cp2 = rtWidget.TopRight(); 1402 cp2 = rtWidget.TopRight();
1390 vx = 1, vy = 1; 1403 vx = 1, vy = 1;
1391 nx = -1, ny = 0; 1404 nx = -1, ny = 0;
1392 if (bRound) { 1405 if (bRound) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 if (i == 0) { 1445 if (i == 0) {
1433 fillPath.MoveTo(cp1.x, cp1.y + fRadius1); 1446 fillPath.MoveTo(cp1.x, cp1.y + fRadius1);
1434 } 1447 }
1435 if (bRound) { 1448 if (bRound) {
1436 if (fRadius1 < 0) { 1449 if (fRadius1 < 0) {
1437 sx -= FX_PI; 1450 sx -= FX_PI;
1438 } 1451 }
1439 if (bInverted) { 1452 if (bInverted) {
1440 sy *= -1; 1453 sy *= -1;
1441 } 1454 }
1455 CFX_RectF rtRadius;
1442 rtRadius.Set(cp1.x, cp1.y, fRadius1 * 2 * vx, fRadius1 * 2 * vy); 1456 rtRadius.Set(cp1.x, cp1.y, fRadius1 * 2 * vx, fRadius1 * 2 * vy);
1443 rtRadius.Normalize(); 1457 rtRadius.Normalize();
1444 if (bInverted) { 1458 if (bInverted) {
1445 rtRadius.Offset(-fRadius1 * vx, -fRadius1 * vy); 1459 rtRadius.Offset(-fRadius1 * vx, -fRadius1 * vy);
1446 } 1460 }
1447 fillPath.ArcTo(rtRadius.left, rtRadius.top, rtRadius.width, 1461 fillPath.ArcTo(rtRadius.left, rtRadius.top, rtRadius.width,
1448 rtRadius.height, sx, sy); 1462 rtRadius.height, sx, sy);
1449 } else { 1463 } else {
1464 CFX_PointF cp;
1450 if (bInverted) { 1465 if (bInverted) {
1451 cp.x = cp1.x + fRadius1 * vx, cp.y = cp1.y + fRadius1 * vy; 1466 cp.x = cp1.x + fRadius1 * vx, cp.y = cp1.y + fRadius1 * vy;
1452 } else { 1467 } else {
1453 cp = cp1; 1468 cp = cp1;
1454 } 1469 }
1455 fillPath.LineTo(cp.x, cp.y); 1470 fillPath.LineTo(cp.x, cp.y);
1456 fillPath.LineTo(cp1.x + fRadius1 * sx, cp1.y + fRadius1 * sy); 1471 fillPath.LineTo(cp1.x + fRadius1 * sx, cp1.y + fRadius1 * sy);
1457 } 1472 }
1458 fillPath.LineTo(cp2.x + fRadius2 * nx, cp2.y + fRadius2 * ny); 1473 fillPath.LineTo(cp2.x + fRadius2 * nx, cp2.y + fRadius2 * ny);
1459 } 1474 }
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
1961 iType != XFA_ELEMENT_Rectangle) { 1976 iType != XFA_ELEMENT_Rectangle) {
1962 return; 1977 return;
1963 } 1978 }
1964 CXFA_StrokeArray strokes; 1979 CXFA_StrokeArray strokes;
1965 if (!(dwFlags & XFA_DRAWBOX_ForceRound) && iType != XFA_ELEMENT_Arc) { 1980 if (!(dwFlags & XFA_DRAWBOX_ForceRound) && iType != XFA_ELEMENT_Arc) {
1966 box.GetStrokes(strokes); 1981 box.GetStrokes(strokes);
1967 } 1982 }
1968 XFA_BOX_Fill(box, strokes, pGS, rtWidget, pMatrix, dwFlags); 1983 XFA_BOX_Fill(box, strokes, pGS, rtWidget, pMatrix, dwFlags);
1969 XFA_BOX_Stroke(box, strokes, pGS, rtWidget, pMatrix, dwFlags); 1984 XFA_BOX_Stroke(box, strokes, pGS, rtWidget, pMatrix, dwFlags);
1970 } 1985 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_ffnotify.cpp ('k') | xfa/fxfa/app/xfa_ffwidgetacc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698