summaryrefslogtreecommitdiffstats
path: root/pdf
diff options
context:
space:
mode:
authordeepak.m1 <deepak.m1@samsung.com>2015-01-08 19:44:18 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-09 03:45:03 +0000
commit8f17ec1cb198cd940d10a9c499d87c118aecd39d (patch)
treea6a96a93fb70406dcd89445f10768bb61b935ab2 /pdf
parent6a4cf3b4810d8391b0962dbacd094b4e42edd6c0 (diff)
downloadchromium_src-8f17ec1cb198cd940d10a9c499d87c118aecd39d.zip
chromium_src-8f17ec1cb198cd940d10a9c499d87c118aecd39d.tar.gz
chromium_src-8f17ec1cb198cd940d10a9c499d87c118aecd39d.tar.bz2
Right clicking outside of a selected area should deselect text and bring up the correct context menu.
on right clink selection was not getting cleared,due to that wrong context menu is coming. Changes done so that when right click on the selected area then selection will stay and proper context menu will come. And when right click have been done outside selection then selection will clear and correct context menu will come. BUG=92800 Review URL: https://codereview.chromium.org/689083002 Cr-Commit-Position: refs/heads/master@{#310706}
Diffstat (limited to 'pdf')
-rw-r--r--pdf/pdfium/pdfium_engine.cc38
-rw-r--r--pdf/pdfium/pdfium_engine.h4
2 files changed, 34 insertions, 8 deletions
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc
index 6cd9cae..2a3ec26 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);
}
diff --git a/pdf/pdfium/pdfium_engine.h b/pdf/pdfium/pdfium_engine.h
index 11d304a..960c5f2 100644
--- a/pdf/pdfium/pdfium_engine.h
+++ b/pdf/pdfium/pdfium_engine.h
@@ -246,6 +246,10 @@ class PDFiumEngine : public PDFEngine,
// PDFiumPage because we might not have that structure when we need this.
pp::Size GetPageSize(int index);
+ void GetAllScreenRectsUnion(std::vector<PDFiumRange>* rect_range,
+ const pp::Point& offset_point,
+ std::vector<pp::Rect>* rect_vector);
+
void UpdateTickMarks();
// Called to continue searching so we don't block the main thread.