Commit 7259b50e authored by Henrique Nakashima's avatar Henrique Nakashima Committed by Commit Bot

In PDF viewer, kill form focus when window loses focus.

Bug: 665554
Change-Id: I96b716d38a51c13a5d94595c2b568f06471a33aa
Reviewed-on: https://chromium-review.googlesource.com/774980Reviewed-by: default avatardsinclair <dsinclair@chromium.org>
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517190}
parent 8e07ac11
......@@ -773,6 +773,11 @@ void OutOfProcessInstance::DidChangeView(const pp::View& view) {
}
}
void OutOfProcessInstance::DidChangeFocus(bool has_focus) {
if (!has_focus)
engine_->KillFormFocus();
}
void OutOfProcessInstance::GetPrintPresetOptionsFromDocument(
PP_PdfPrintPresetOptions_Dev* options) {
options->is_scaling_disabled = PP_FromBool(IsPrintScalingDisabled());
......
......@@ -53,6 +53,7 @@ class OutOfProcessInstance : public pp::Instance,
void HandleMessage(const pp::Var& message) override;
bool HandleInputEvent(const pp::InputEvent& event) override;
void DidChangeView(const pp::View& view) override;
void DidChangeFocus(bool has_focus) override;
// pp::Find_Private implementation.
bool StartFind(const std::string& text, bool case_sensitive) override;
......
......@@ -348,6 +348,9 @@ class PDFEngine {
virtual void MoveRangeSelectionExtent(const pp::Point& extent) = 0;
virtual void SetSelectionBounds(const pp::Point& base,
const pp::Point& extent) = 0;
// Remove focus from form widgets, consolidating the user input.
virtual void KillFormFocus() = 0;
};
// Interface for exports that wrap the PDF engine.
......
......@@ -1537,7 +1537,7 @@ pp::Buffer_Dev PDFiumEngine::PrintPagesAsRasterPDF(
if (!output_doc)
return pp::Buffer_Dev();
SaveSelectedFormForPrint();
KillFormFocus();
std::vector<PDFiumPage> pages_to_print;
// width and height of source PDF pages.
......@@ -1637,7 +1637,7 @@ pp::Buffer_Dev PDFiumEngine::PrintPagesAsPDF(
if (!output_doc)
return pp::Buffer_Dev();
SaveSelectedFormForPrint();
KillFormFocus();
std::string page_number_str;
for (uint32_t index = 0; index < page_range_count; ++index) {
......@@ -1691,7 +1691,7 @@ void PDFiumEngine::FitContentsToPrintableAreaIfRequired(
}
}
void PDFiumEngine::SaveSelectedFormForPrint() {
void PDFiumEngine::KillFormFocus() {
FORM_ForceToKillFocus(form_);
SetInFormTextArea(false);
}
......
......@@ -120,6 +120,7 @@ class PDFiumEngine : public PDFEngine,
void OnDocumentComplete() override;
void OnDocumentCanceled() override;
void CancelBrowserDownload() override;
void KillFormFocus() override;
void UnsupportedFeature(int type);
void FontSubstituted();
......@@ -333,7 +334,6 @@ class PDFiumEngine : public PDFEngine,
void FitContentsToPrintableAreaIfRequired(
FPDF_DOCUMENT doc,
const PP_PrintSettings_Dev& print_settings);
void SaveSelectedFormForPrint();
// Checks if |page| has selected text in a form element. If so, sets that as
// the plugin's text selection.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment