Remove dead code: CPWL_Edit::CutText() The behavior difference is that now for some embedders shift+delete is allowed in password fields by PDFium. Additionally FORM_OnChar now returns false for ctrl+x. Lastly PDFium would internally delete the selected text on ctrl+x previously. It's possible some embedders use that ctrl+x behavior but PDFium has not actually put the text in the clipboard since at least 2016, possibly even broken in 2015. ClearSelection() internally checks if there is a selection or if the field is read-only so those checks aren't needed. In Chrome shift+delete works via ExecuteEditCommand() and bypasses this handler. Also Chrome never sent the ctrl+x OnChar event to PDFium before so the ClearSelection() call path wasn't used either. Change-Id: Ie5f120b0292171caeb3c493ec804ec0483603f85 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/137130 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: April Kallmeyer <ask@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/pwl/cpwl_edit.cpp b/fpdfsdk/pwl/cpwl_edit.cpp index 10b9e86..b87edf5 100644 --- a/fpdfsdk/pwl/cpwl_edit.cpp +++ b/fpdfsdk/pwl/cpwl_edit.cpp
@@ -91,21 +91,6 @@ return GetSelectWordRange() != edit_impl_->GetWholeWordRange(); } -bool CPWL_Edit::CanCopy() const { - return !HasFlag(PES_PASSWORD) && edit_impl_->IsSelected(); -} - -bool CPWL_Edit::CanCut() const { - return CanCopy() && !IsReadOnly(); -} - -void CPWL_Edit::CutText() { - if (!CanCut()) { - return; - } - edit_impl_->ClearSelection(); -} - void CPWL_Edit::OnCreated() { SetFontSize(GetCreationParams()->fFontSize); edit_impl_->SetFontMap(GetFontMap()); @@ -547,11 +532,7 @@ edit_impl_->OnVK_END(IsSHIFTKeyDown(nFlag), IsCTRLKeyDown(nFlag)); return true; case FWL_VKEY_Unknown: - if (!IsSHIFTKeyDown(nFlag)) { - ClearSelection(); - } else { - CutText(); - } + ClearSelection(); return true; default: return false; @@ -582,9 +563,6 @@ if (bCtrl && !bAlt) { switch (nChar) { - case pdfium::ascii::kControlX: - CutText(); - return true; case pdfium::ascii::kControlA: SelectAllText(); return true;
diff --git a/fpdfsdk/pwl/cpwl_edit.h b/fpdfsdk/pwl/cpwl_edit.h index 820eb85..1cff95c 100644 --- a/fpdfsdk/pwl/cpwl_edit.h +++ b/fpdfsdk/pwl/cpwl_edit.h
@@ -86,9 +86,6 @@ void SetCharArray(int32_t nCharArray); void SetLimitChar(int32_t nLimitChar); bool CanSelectAll() const; - bool CanCopy() const; - bool CanCut() const; - void CutText(); void SetText(const WideString& csText); bool IsTextFull() const; void SetMaxUndoItemsForTest(size_t items);