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

Side by Side Diff: core/src/fpdfdoc/doc_annot.cpp

Issue 1143663008: Merge to XFA: Remove FX_Alloc() null checks now that it can't return NULL. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Rebased. Created 5 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 | « core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp ('k') | core/src/fpdftext/fpdf_text.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 "../../../third_party/base/nonstd_unique_ptr.h" 7 #include "../../../third_party/base/nonstd_unique_ptr.h"
8 #include "../../include/fpdfdoc/fpdf_doc.h" 8 #include "../../include/fpdfdoc/fpdf_doc.h"
9 #include "../../include/fpdfapi/fpdf_pageobj.h" 9 #include "../../include/fpdfapi/fpdf_pageobj.h"
10 10
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 pColorData->m_StrokeRGB = argb; 338 pColorData->m_StrokeRGB = argb;
339 pPathObject->m_bStroke = TRUE; 339 pPathObject->m_bStroke = TRUE;
340 pPathObject->m_FillType = 0; 340 pPathObject->m_FillType = 0;
341 if (style_char == 'D') { 341 if (style_char == 'D') {
342 if (pDashArray) { 342 if (pDashArray) {
343 FX_DWORD dash_count = pDashArray->GetCount(); 343 FX_DWORD dash_count = pDashArray->GetCount();
344 if (dash_count % 2) { 344 if (dash_count % 2) {
345 dash_count ++; 345 dash_count ++;
346 } 346 }
347 pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, dash_count); 347 pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, dash_count);
348 if (pGraphState->m_DashArray == NULL) {
349 return NULL;
350 }
351 pGraphState->m_DashCount = dash_count; 348 pGraphState->m_DashCount = dash_count;
352 FX_DWORD i; 349 FX_DWORD i;
353 for (i = 0; i < pDashArray->GetCount(); i ++) { 350 for (i = 0; i < pDashArray->GetCount(); i ++) {
354 pGraphState->m_DashArray[i] = pDashArray->GetNumber(i); 351 pGraphState->m_DashArray[i] = pDashArray->GetNumber(i);
355 } 352 }
356 if (i < dash_count) { 353 if (i < dash_count) {
357 pGraphState->m_DashArray[i] = pGraphState->m_DashArray[i - 1]; 354 pGraphState->m_DashArray[i] = pGraphState->m_DashArray[i - 1];
358 } 355 }
359 } else { 356 } else {
360 pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, 2); 357 pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, 2);
361 if (pGraphState->m_DashArray == NULL) {
362 return NULL;
363 }
364 pGraphState->m_DashCount = 2; 358 pGraphState->m_DashCount = 2;
365 pGraphState->m_DashArray[0] = pGraphState->m_DashArray[1] = 3 * 1.0f ; 359 pGraphState->m_DashArray[0] = pGraphState->m_DashArray[1] = 3 * 1.0f ;
366 } 360 }
367 } 361 }
368 CFX_FloatRect rect; 362 CFX_FloatRect rect;
369 GetRect(rect); 363 GetRect(rect);
370 width /= 2; 364 width /= 2;
371 CPDF_PathData *pPathData = pPathObject->m_Path.GetModify(); 365 CPDF_PathData *pPathData = pPathObject->m_Path.GetModify();
372 if (pPathData) { 366 if (pPathData) {
373 pPathData->AppendRect(rect.left + width, rect.bottom + width, rect.right - width, rect.top - width); 367 pPathData->AppendRect(rect.left + width, rect.bottom + width, rect.right - width, rect.top - width);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 } 434 }
441 CPDF_GraphStateData graph_state; 435 CPDF_GraphStateData graph_state;
442 graph_state.m_LineWidth = width; 436 graph_state.m_LineWidth = width;
443 if (style_char == 'D') { 437 if (style_char == 'D') {
444 if (pDashArray) { 438 if (pDashArray) {
445 FX_DWORD dash_count = pDashArray->GetCount(); 439 FX_DWORD dash_count = pDashArray->GetCount();
446 if (dash_count % 2) { 440 if (dash_count % 2) {
447 dash_count ++; 441 dash_count ++;
448 } 442 }
449 graph_state.m_DashArray = FX_Alloc(FX_FLOAT, dash_count); 443 graph_state.m_DashArray = FX_Alloc(FX_FLOAT, dash_count);
450 if (graph_state.m_DashArray == NULL) {
451 return ;
452 }
453 graph_state.m_DashCount = dash_count; 444 graph_state.m_DashCount = dash_count;
454 FX_DWORD i; 445 FX_DWORD i;
455 for (i = 0; i < pDashArray->GetCount(); i ++) { 446 for (i = 0; i < pDashArray->GetCount(); i ++) {
456 graph_state.m_DashArray[i] = pDashArray->GetNumber(i); 447 graph_state.m_DashArray[i] = pDashArray->GetNumber(i);
457 } 448 }
458 if (i < dash_count) { 449 if (i < dash_count) {
459 graph_state.m_DashArray[i] = graph_state.m_DashArray[i - 1]; 450 graph_state.m_DashArray[i] = graph_state.m_DashArray[i - 1];
460 } 451 }
461 } else { 452 } else {
462 graph_state.m_DashArray = FX_Alloc(FX_FLOAT, 2); 453 graph_state.m_DashArray = FX_Alloc(FX_FLOAT, 2);
463 if (graph_state.m_DashArray == NULL) {
464 return ;
465 }
466 graph_state.m_DashCount = 2; 454 graph_state.m_DashCount = 2;
467 graph_state.m_DashArray[0] = graph_state.m_DashArray[1] = 3 * 1.0f; 455 graph_state.m_DashArray[0] = graph_state.m_DashArray[1] = 3 * 1.0f;
468 } 456 }
469 } 457 }
470 CFX_FloatRect rect; 458 CFX_FloatRect rect;
471 GetRect(rect); 459 GetRect(rect);
472 CPDF_PathData path; 460 CPDF_PathData path;
473 width /= 2; 461 width /= 2;
474 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, rect.top - width); 462 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, rect.top - width);
475 int fill_type = 0; 463 int fill_type = 0;
(...skipping 30 matching lines...) Expand all
506 if (pIRT != m_pAnnotDict) { 494 if (pIRT != m_pAnnotDict) {
507 continue; 495 continue;
508 } 496 }
509 if (count == index) { 497 if (count == index) {
510 return pAnnot; 498 return pAnnot;
511 } 499 }
512 count ++; 500 count ++;
513 } 501 }
514 return NULL; 502 return NULL;
515 } 503 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp ('k') | core/src/fpdftext/fpdf_text.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698