Add backend support for displaying/hiding PDF annotations.
Add message handling in the PDF plugin for displaying/hiding PDF annotations and hook it up to PDFiumEngine, which already has support for this feature. Bug: 642982 Change-Id: I18f4dfb9aed4639936d9392a260289224f5dc1f9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2242793 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Daniel Hosseinian <dhoss@chromium.org> Cr-Commit-Position: refs/heads/master@{#778997}
This commit is contained in:
@ -163,6 +163,9 @@ constexpr char kJSRotateCounterclockwiseType[] = "rotateCounterclockwise";
|
||||
// Toggle two-up view (Page -> Plugin)
|
||||
constexpr char kJSSetTwoUpViewType[] = "setTwoUpView";
|
||||
constexpr char kJSEnableTwoUpView[] = "enableTwoUpView";
|
||||
// Display annotations (Page -> Plugin)
|
||||
constexpr char kJSDisplayAnnotationsType[] = "displayAnnotations";
|
||||
constexpr char kJSDisplayAnnotations[] = "display";
|
||||
// Select all text in the document (Page -> Plugin)
|
||||
constexpr char kJSSelectAllType[] = "selectAll";
|
||||
// Get the selected text in the document (Page -> Plugin)
|
||||
@ -565,6 +568,8 @@ void OutOfProcessInstance::HandleMessage(const pp::Var& message) {
|
||||
RotateCounterclockwise();
|
||||
} else if (type == kJSSetTwoUpViewType) {
|
||||
HandleSetTwoUpViewMessage(dict);
|
||||
} else if (type == kJSDisplayAnnotationsType) {
|
||||
HandleDisplayAnnotations(dict);
|
||||
} else if (type == kJSSelectAllType) {
|
||||
engine_->SelectAll();
|
||||
} else if (type == kJSBackgroundColorChangedType) {
|
||||
@ -1514,6 +1519,17 @@ void OutOfProcessInstance::HandleBackgroundColorChangedMessage(
|
||||
&background_color_);
|
||||
}
|
||||
|
||||
void OutOfProcessInstance::HandleDisplayAnnotations(
|
||||
const pp::VarDictionary& dict) {
|
||||
if (!dict.Get(pp::Var(kJSDisplayAnnotations)).is_bool()) {
|
||||
NOTREACHED();
|
||||
return;
|
||||
}
|
||||
|
||||
engine_->DisplayAnnotations(
|
||||
dict.Get(pp::Var(kJSDisplayAnnotations)).AsBool());
|
||||
}
|
||||
|
||||
void OutOfProcessInstance::HandleGetNamedDestinationMessage(
|
||||
const pp::VarDictionary& dict) {
|
||||
if (!dict.Get(pp::Var(kJSGetNamedDestination)).is_string()) {
|
||||
|
@ -163,6 +163,7 @@ class OutOfProcessInstance : public pp::Instance,
|
||||
private:
|
||||
// Message handlers.
|
||||
void HandleBackgroundColorChangedMessage(const pp::VarDictionary& dict);
|
||||
void HandleDisplayAnnotations(const pp::VarDictionary& dict);
|
||||
void HandleGetNamedDestinationMessage(const pp::VarDictionary& dict);
|
||||
void HandleGetPasswordCompleteMessage(const pp::VarDictionary& dict);
|
||||
void HandleGetSelectedTextMessage();
|
||||
|
@ -343,6 +343,7 @@ class PDFEngine {
|
||||
virtual void RotateClockwise() = 0;
|
||||
virtual void RotateCounterclockwise() = 0;
|
||||
virtual void SetTwoUpView(bool enable) = 0;
|
||||
virtual void DisplayAnnotations(bool display) = 0;
|
||||
|
||||
// Applies the document layout options proposed by a call to
|
||||
// PDFEngine::Client::ProposeDocumentLayout(), returning the overall size of
|
||||
|
@ -2008,6 +2008,14 @@ void PDFiumEngine::SetTwoUpView(bool enable) {
|
||||
ProposeNextDocumentLayout();
|
||||
}
|
||||
|
||||
void PDFiumEngine::DisplayAnnotations(bool display) {
|
||||
if (render_annots_ == display)
|
||||
return;
|
||||
|
||||
render_annots_ = display;
|
||||
InvalidateAllPages();
|
||||
}
|
||||
|
||||
void PDFiumEngine::InvalidateAllPages() {
|
||||
CancelPaints();
|
||||
StopFind();
|
||||
|
@ -100,6 +100,7 @@ class PDFiumEngine : public PDFEngine,
|
||||
void RotateClockwise() override;
|
||||
void RotateCounterclockwise() override;
|
||||
void SetTwoUpView(bool enable) override;
|
||||
void DisplayAnnotations(bool display) override;
|
||||
pp::Size ApplyDocumentLayout(const DocumentLayout::Options& options) override;
|
||||
std::string GetSelectedText() override;
|
||||
bool CanEditText() override;
|
||||
|
Reference in New Issue
Block a user