Index: pdf/pdfium/pdfium_engine.cc |
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc |
index 8c49b9dc0bc67a56ed1bb3732a394ae62ec88ccb..3b18e3f3da3670fab62b066cb531e47d0bd31e24 100644 |
--- a/pdf/pdfium/pdfium_engine.cc |
+++ b/pdf/pdfium/pdfium_engine.cc |
@@ -1605,8 +1605,24 @@ PDFiumPage::Area PDFiumEngine::GetCharIndex( |
} |
bool PDFiumEngine::OnMouseDown(const pp::MouseInputEvent& event) { |
- if (event.GetButton() != PP_INPUTEVENT_MOUSEBUTTON_LEFT) |
- return false; |
+ if (event.GetButton() != PP_INPUTEVENT_MOUSEBUTTON_LEFT) { |
gene
2015/01/06 18:40:04
We probably don't want to erase selection for midd
Deepak
2015/01/07 04:59:01
Done.
|
+ if (!selection_.size()) |
+ return false; |
+ pp::Rect selection_rect; |
+ std::vector<pp::Rect> selection_rect_vector; |
+ GetAllScreenRectsUnion(selection_, GetVisibleRect().point(), |
+ selection_rect_vector); |
+ for (size_t i = 0; i < selection_rect_vector.size(); ++i) |
+ selection_rect = selection_rect.Union(selection_rect_vector[i]); |
gene
2015/01/06 18:40:04
Why do you want to unite all rects, instead of tes
Deepak
2015/01/07 04:59:01
I agree with you. This will help us in early retur
|
+ |
+ pp::Point point = event.GetPosition(); |
+ if (selection_rect.IsEmpty() || |
+ selection_rect.Contains(point.x(), point.y())) |
+ return false; |
+ SelectionChangeInvalidator selection_invalidator(this); |
+ selection_.clear(); |
+ return true; |
+ } |
SelectionChangeInvalidator selection_invalidator(this); |
selection_.clear(); |
@@ -2178,18 +2194,22 @@ 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 (size_t i = 0; i < rect_range.size(); ++i) { |
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 = rect_range[i].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); |
} |