Simplify code in CPWL_EditCtrl::SetCursor(). - GetSystemHandler() always returns non-null. - Use a ternary operator. - Also mark CPWL_EditCtrl::IsWndHorV() const. Change-Id: I23d54fff280d527864b21298ee5e6f298b94e480 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/58811 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/pwl/cpwl_edit_ctrl.cpp b/fpdfsdk/pwl/cpwl_edit_ctrl.cpp index 9b874c1..28d9168 100644 --- a/fpdfsdk/pwl/cpwl_edit_ctrl.cpp +++ b/fpdfsdk/pwl/cpwl_edit_ctrl.cpp
@@ -34,20 +34,14 @@ m_pEdit->Initialize(); } -bool CPWL_EditCtrl::IsWndHorV() { +bool CPWL_EditCtrl::IsWndHorV() const { CFX_Matrix mt = GetWindowMatrix(); return mt.Transform(CFX_PointF(1, 1)).y == mt.Transform(CFX_PointF(0, 1)).y; } void CPWL_EditCtrl::SetCursor() { - if (IsValid()) { - if (IPWL_SystemHandler* pSH = GetSystemHandler()) { - if (IsWndHorV()) - pSH->SetCursor(FXCT_VBEAM); - else - pSH->SetCursor(FXCT_HBEAM); - } - } + if (IsValid()) + GetSystemHandler()->SetCursor(IsWndHorV() ? FXCT_VBEAM : FXCT_HBEAM); } WideString CPWL_EditCtrl::GetSelectedText() {
diff --git a/fpdfsdk/pwl/cpwl_edit_ctrl.h b/fpdfsdk/pwl/cpwl_edit_ctrl.h index aeeb7f6..df504d8 100644 --- a/fpdfsdk/pwl/cpwl_edit_ctrl.h +++ b/fpdfsdk/pwl/cpwl_edit_ctrl.h
@@ -74,7 +74,7 @@ void CutText(); void InsertWord(uint16_t word, int32_t nCharset); void InsertReturn(); - bool IsWndHorV(); + bool IsWndHorV() const; void Delete(); void Backspace(); void GetCaretInfo(CFX_PointF* ptHead, CFX_PointF* ptFoot) const;