Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "../../include/pdfwindow/PDFWindow.h" | 7 #include "../../include/pdfwindow/PDFWindow.h" |
| 8 #include "../../include/pdfwindow/PWL_Wnd.h" | 8 #include "../../include/pdfwindow/PWL_Wnd.h" |
| 9 #include "../../include/pdfwindow/PWL_EditCtrl.h" | 9 #include "../../include/pdfwindow/PWL_EditCtrl.h" |
| 10 #include "../../include/pdfwindow/PWL_Edit.h" | 10 #include "../../include/pdfwindow/PWL_Edit.h" |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 404 } | 404 } |
| 405 | 405 |
| 406 void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser 2Device) | 406 void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser 2Device) |
| 407 { | 407 { |
| 408 CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device); | 408 CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device); |
| 409 | 409 |
| 410 CPDF_Rect rcClient = GetClientRect(); | 410 CPDF_Rect rcClient = GetClientRect(); |
| 411 CFX_ByteTextBuf sLine; | 411 CFX_ByteTextBuf sLine; |
| 412 | 412 |
| 413 FX_INT32 nCharArray = m_pEdit->GetCharArray(); | 413 FX_INT32 nCharArray = m_pEdit->GetCharArray(); |
| 414 FX_SAFE_INT32 nCharArrayDouble = nCharArray; | |
|
Tom Sepez
2014/08/18 18:15:47
nit: Can we call this nCharArraySafe? Double soun
Bo Xu
2014/08/18 18:33:58
Done.
| |
| 415 nCharArrayDouble -= 1; | |
| 416 nCharArrayDouble *= 2; | |
| 414 | 417 |
| 415 » if (nCharArray > 0) | 418 » if (nCharArray > 0 && nCharArrayDouble.IsValid()) |
| 416 { | 419 { |
| 417 switch (GetBorderStyle()) | 420 switch (GetBorderStyle()) |
| 418 { | 421 { |
| 419 case PBS_SOLID: | 422 case PBS_SOLID: |
| 420 { | 423 { |
| 421 CFX_GraphStateData gsd; | 424 CFX_GraphStateData gsd; |
| 422 gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); | 425 gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); |
| 423 | 426 |
| 424 CFX_PathData path; | 427 CFX_PathData path; |
| 425 » » » » path.SetPointCount((nCharArray-1)*2); | 428 » » » » if (!path.SetPointCount(nCharArrayDouble.ValueOr Die())) { |
| 429 » » » » » return; | |
| 430 » » » » } | |
| 426 | 431 |
| 427 for (FX_INT32 i=0; i<nCharArray-1; i++) | 432 for (FX_INT32 i=0; i<nCharArray-1; i++) |
| 428 { | 433 { |
| 429 path.SetPoint(i*2, rcClient.left + ((rcC lient.right - rcClient.left)/nCharArray)*(i+1), | 434 path.SetPoint(i*2, rcClient.left + ((rcC lient.right - rcClient.left)/nCharArray)*(i+1), |
| 430 rcClient.bottom, FXPT_MOVETO); | 435 rcClient.bottom, FXPT_MOVETO); |
| 431 path.SetPoint(i*2+1, rcClient.left + ((r cClient.right - rcClient.left)/nCharArray)*(i+1), | 436 path.SetPoint(i*2+1, rcClient.left + ((r cClient.right - rcClient.left)/nCharArray)*(i+1), |
| 432 rcClient.top, FXPT_LINETO); | 437 rcClient.top, FXPT_LINETO); |
| 433 } | 438 } |
| 434 if (path.GetPointCount() > 0) | 439 if (path.GetPointCount() > 0) |
| 435 pDevice->DrawPath(&path, pUser2Device, & gsd,0, | 440 pDevice->DrawPath(&path, pUser2Device, & gsd,0, |
| 436 CPWL_Utils::PWLColorToFXColor(Ge tBorderColor(),255), FXFILL_ALTERNATE); | 441 CPWL_Utils::PWLColorToFXColor(Ge tBorderColor(),255), FXFILL_ALTERNATE); |
| 437 } | 442 } |
| 438 break; | 443 break; |
| 439 case PBS_DASH: | 444 case PBS_DASH: |
| 440 { | 445 { |
| 441 CFX_GraphStateData gsd; | 446 CFX_GraphStateData gsd; |
| 442 gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); | 447 gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); |
| 443 | 448 |
| 444 gsd.SetDashCount(2); | 449 gsd.SetDashCount(2); |
| 445 gsd.m_DashArray[0] = (FX_FLOAT)GetBorderDash().n Dash; | 450 gsd.m_DashArray[0] = (FX_FLOAT)GetBorderDash().n Dash; |
| 446 gsd.m_DashArray[1] = (FX_FLOAT)GetBorderDash().n Gap; | 451 gsd.m_DashArray[1] = (FX_FLOAT)GetBorderDash().n Gap; |
| 447 gsd.m_DashPhase = (FX_FLOAT)GetBorderDash().nPha se; | 452 gsd.m_DashPhase = (FX_FLOAT)GetBorderDash().nPha se; |
| 448 | 453 |
| 449 CFX_PathData path; | 454 CFX_PathData path; |
| 450 » » » » path.SetPointCount((nCharArray-1)*2); | 455 » » » » if (!path.SetPointCount(nCharArrayDouble.ValueOr Die())) { |
| 456 » » » » » return; | |
| 457 » » » » } | |
| 451 | 458 |
| 452 for (FX_INT32 i=0; i<nCharArray-1; i++) | 459 for (FX_INT32 i=0; i<nCharArray-1; i++) |
| 453 { | 460 { |
| 454 path.SetPoint(i*2, rcClient.left + ((rcC lient.right - rcClient.left)/nCharArray)*(i+1), | 461 path.SetPoint(i*2, rcClient.left + ((rcC lient.right - rcClient.left)/nCharArray)*(i+1), |
| 455 rcClient.bottom, FXPT_MOVETO); | 462 rcClient.bottom, FXPT_MOVETO); |
| 456 path.SetPoint(i*2+1, rcClient.left + ((r cClient.right - rcClient.left)/nCharArray)*(i+1), | 463 path.SetPoint(i*2+1, rcClient.left + ((r cClient.right - rcClient.left)/nCharArray)*(i+1), |
| 457 rcClient.top, FXPT_LINETO); | 464 rcClient.top, FXPT_LINETO); |
| 458 } | 465 } |
| 459 if (path.GetPointCount() > 0) | 466 if (path.GetPointCount() > 0) |
| 460 pDevice->DrawPath(&path, pUser2Device, & gsd,0, | 467 pDevice->DrawPath(&path, pUser2Device, & gsd,0, |
| (...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1307 IFX_Edit::GeneratePageObjects(pPageObjects, m_pEdit, ptOffset, NULL, CPW L_Utils::PWLColorToFXColor(GetTextColor(),GetTransparency()), ObjArray); | 1314 IFX_Edit::GeneratePageObjects(pPageObjects, m_pEdit, ptOffset, NULL, CPW L_Utils::PWLColorToFXColor(GetTextColor(),GetTransparency()), ObjArray); |
| 1308 } | 1315 } |
| 1309 | 1316 |
| 1310 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjects* pPageObjects, | 1317 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjects* pPageObjects, |
| 1311 const CP DF_Point& ptOffset) | 1318 const CP DF_Point& ptOffset) |
| 1312 { | 1319 { |
| 1313 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; | 1320 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; |
| 1314 IFX_Edit::GeneratePageObjects(pPageObjects, m_pEdit, ptOffset, NULL, CPW L_Utils::PWLColorToFXColor(GetTextColor(),GetTransparency()), ObjArray); | 1321 IFX_Edit::GeneratePageObjects(pPageObjects, m_pEdit, ptOffset, NULL, CPW L_Utils::PWLColorToFXColor(GetTextColor(),GetTransparency()), ObjArray); |
| 1315 } | 1322 } |
| 1316 | 1323 |
| OLD | NEW |