diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2018-01-11 16:35:12 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-01-11 16:35:12 +0000 |
commit | ce7df754b0608887a923d5083f0bbb999a735fce (patch) | |
tree | 03c73474e98e7832eb6601e5933707f3ec087653 /fxjs/xfa | |
parent | b800d149de09ac7d73aa3d1ff8558e33a4c56009 (diff) | |
download | pdfium-ce7df754b0608887a923d5083f0bbb999a735fce.tar.xz |
Rename CXFA_Box methods to make return clearer
This CL renames the methods in CXFA_Box to make it clearer they can
return nullptr.
Change-Id: I521c0e06af306f69e390a4057cabb7777a0d72f5
Reviewed-on: https://pdfium-review.googlesource.com/22740
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fxjs/xfa')
-rw-r--r-- | fxjs/xfa/cjx_object.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp index 8608cc0e8d..6408cf3eb9 100644 --- a/fxjs/xfa/cjx_object.cpp +++ b/fxjs/xfa/cjx_object.cpp @@ -1323,7 +1323,7 @@ void CJX_Object::Script_Som_FillColor(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { CXFA_Border* border = ToNode(object_.Get())->GetOrCreateBorderIfPossible(); - CXFA_Fill* borderfill = border->GetOrCreateFill(); + CXFA_Fill* borderfill = border->GetOrCreateFillIfPossible(); if (!borderfill) return; @@ -1358,13 +1358,17 @@ void CJX_Object::Script_Som_BorderColor(CFXJSE_Value* pValue, int32_t b = 0; std::tie(r, g, b) = StrToRGB(pValue->ToWideString()); FX_ARGB rgb = ArgbEncode(100, r, g, b); - for (int32_t i = 0; i < iSize; ++i) - border->GetEdge(i)->SetColor(rgb); + for (int32_t i = 0; i < iSize; ++i) { + CXFA_Edge* edge = border->GetEdgeIfExists(i); + if (edge) + edge->SetColor(rgb); + } return; } - FX_ARGB color = border->GetEdge(0)->GetColor(); + CXFA_Edge* edge = border->GetEdgeIfExists(0); + FX_ARGB color = edge ? edge->GetColor() : CXFA_Edge::kDefaultColor; int32_t a; int32_t r; int32_t g; @@ -1379,15 +1383,18 @@ void CJX_Object::Script_Som_BorderWidth(CFXJSE_Value* pValue, XFA_Attribute eAttribute) { CXFA_Border* border = ToNode(object_.Get())->GetOrCreateBorderIfPossible(); if (bSetting) { - CXFA_Measurement thickness = border->GetEdge(0)->GetMSThickness(); + CXFA_Edge* edge = border->GetEdgeIfExists(0); + CXFA_Measurement thickness = + edge ? edge->GetMSThickness() : CXFA_Measurement(0.5, XFA_Unit::Pt); pValue->SetString(thickness.ToString().UTF8Encode().AsStringView()); return; } WideString wsThickness = pValue->ToWideString(); for (int32_t i = 0; i < border->CountEdges(); ++i) { - border->GetEdge(i)->SetMSThickness( - CXFA_Measurement(wsThickness.AsStringView())); + CXFA_Edge* edge = border->GetEdgeIfExists(i); + if (edge) + edge->SetMSThickness(CXFA_Measurement(wsThickness.AsStringView())); } } |