Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Unified Diff: pdf/pdfium/pdfium_engine.cc

Issue 689083002: Right clicking outside of a selected area should deselect text and bring up the correct context men… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing nit. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/pdfium/pdfium_engine.cc
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc
index 6cd9cae4f9974104ef0879c11b3732ba52a23964..2a3ec26c49e17965bf377651c5afba0b4ba6b7c4 100644
--- a/pdf/pdfium/pdfium_engine.cc
+++ b/pdf/pdfium/pdfium_engine.cc
@@ -1605,8 +1605,25 @@ PDFiumPage::Area PDFiumEngine::GetCharIndex(
}
bool PDFiumEngine::OnMouseDown(const pp::MouseInputEvent& event) {
- if (event.GetButton() != PP_INPUTEVENT_MOUSEBUTTON_LEFT)
+ if (event.GetButton() != PP_INPUTEVENT_MOUSEBUTTON_LEFT &&
+ event.GetButton() != PP_INPUTEVENT_MOUSEBUTTON_RIGHT) {
return false;
+ }
+ if (event.GetButton() == PP_INPUTEVENT_MOUSEBUTTON_RIGHT) {
+ if (!selection_.size())
+ return false;
+ std::vector<pp::Rect> selection_rect_vector;
+ GetAllScreenRectsUnion(&selection_, GetVisibleRect().point(),
+ &selection_rect_vector);
+ pp::Point point = event.GetPosition();
+ for (size_t i = 0; i < selection_rect_vector.size(); ++i) {
+ if (selection_rect_vector[i].Contains(point.x(), point.y()))
+ return false;
+ }
+ SelectionChangeInvalidator selection_invalidator(this);
+ selection_.clear();
+ return true;
+ }
SelectionChangeInvalidator selection_invalidator(this);
selection_.clear();
@@ -2186,18 +2203,23 @@ void PDFiumEngine::StopFind() {
find_factory_.CancelAll();
}
-void PDFiumEngine::UpdateTickMarks() {
- std::vector<pp::Rect> tickmarks;
- for (size_t i = 0; i < find_results_.size(); ++i) {
+void PDFiumEngine::GetAllScreenRectsUnion(std::vector<PDFiumRange>* rect_range,
+ const pp::Point& offset_point,
+ std::vector<pp::Rect>* rect_vector) {
+ for (std::vector<PDFiumRange>::iterator it = rect_range->begin();
+ it != rect_range->end(); ++it) {
pp::Rect rect;
- // Always use an origin of 0,0 since scroll positions don't affect tickmark.
- std::vector<pp::Rect> rects = find_results_[i].GetScreenRects(
- pp::Point(0, 0), current_zoom_, current_rotation_);
+ std::vector<pp::Rect> rects =
+ it->GetScreenRects(offset_point, current_zoom_, current_rotation_);
for (size_t j = 0; j < rects.size(); ++j)
rect = rect.Union(rects[j]);
- tickmarks.push_back(rect);
+ rect_vector->push_back(rect);
}
+}
+void PDFiumEngine::UpdateTickMarks() {
+ std::vector<pp::Rect> tickmarks;
+ GetAllScreenRectsUnion(&find_results_, pp::Point(0, 0), &tickmarks);
client_->UpdateTickMarks(tickmarks);
}
« no previous file with comments | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698