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

Side by Side 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: Changes as per review comments 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 unified diff | Download patch
« no previous file with comments | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "pdf/pdfium/pdfium_engine.h" 5 #include "pdf/pdfium/pdfium_engine.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 if (progressive_paints_[i].page_index == page) 1598 if (progressive_paints_[i].page_index == page)
1599 return PDFiumPage::NONSELECTABLE_AREA; 1599 return PDFiumPage::NONSELECTABLE_AREA;
1600 } 1600 }
1601 1601
1602 *page_index = page; 1602 *page_index = page;
1603 return pages_[page]->GetCharIndex(point, current_rotation_, char_index, 1603 return pages_[page]->GetCharIndex(point, current_rotation_, char_index,
1604 target); 1604 target);
1605 } 1605 }
1606 1606
1607 bool PDFiumEngine::OnMouseDown(const pp::MouseInputEvent& event) { 1607 bool PDFiumEngine::OnMouseDown(const pp::MouseInputEvent& event) {
1608 if (event.GetButton() != PP_INPUTEVENT_MOUSEBUTTON_LEFT) 1608 if (event.GetButton() != PP_INPUTEVENT_MOUSEBUTTON_LEFT &&
1609 event.GetButton() != PP_INPUTEVENT_MOUSEBUTTON_RIGHT) {
1609 return false; 1610 return false;
1611 }
1612 if (event.GetButton() == PP_INPUTEVENT_MOUSEBUTTON_RIGHT) {
1613 if (!selection_.size())
1614 return false;
1615 std::vector<pp::Rect> selection_rect_vector;
1616 GetAllScreenRectsUnion(&selection_, GetVisibleRect().point(),
1617 &selection_rect_vector);
1618 pp::Point point = event.GetPosition();
1619 for (size_t i = 0; i < selection_rect_vector.size(); ++i) {
1620 if (selection_rect_vector[i].Contains(point.x(), point.y()))
1621 return false;
1622 }
1623 SelectionChangeInvalidator selection_invalidator(this);
1624 selection_.clear();
1625 return true;
1626 }
1610 1627
1611 SelectionChangeInvalidator selection_invalidator(this); 1628 SelectionChangeInvalidator selection_invalidator(this);
1612 selection_.clear(); 1629 selection_.clear();
1613 1630
1614 int page_index = -1; 1631 int page_index = -1;
1615 int char_index = -1; 1632 int char_index = -1;
1616 PDFiumPage::LinkTarget target; 1633 PDFiumPage::LinkTarget target;
1617 PDFiumPage::Area area = GetCharIndex(event, &page_index, 1634 PDFiumPage::Area area = GetCharIndex(event, &page_index,
1618 &char_index, &target); 1635 &char_index, &target);
1619 mouse_down_state_.Set(area, target); 1636 mouse_down_state_.Set(area, target);
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
2179 find_results_.clear(); 2196 find_results_.clear();
2180 next_page_to_search_ = -1; 2197 next_page_to_search_ = -1;
2181 last_page_to_search_ = -1; 2198 last_page_to_search_ = -1;
2182 last_character_index_to_search_ = -1; 2199 last_character_index_to_search_ = -1;
2183 current_find_index_.Invalidate(); 2200 current_find_index_.Invalidate();
2184 current_find_text_.clear(); 2201 current_find_text_.clear();
2185 UpdateTickMarks(); 2202 UpdateTickMarks();
2186 find_factory_.CancelAll(); 2203 find_factory_.CancelAll();
2187 } 2204 }
2188 2205
2206 void PDFiumEngine::GetAllScreenRectsUnion(std::vector<PDFiumRange>* rect_range,
2207 const pp::Point& offset_point,
2208 std::vector<pp::Rect>* rect_vector) {
2209 for (std::vector<PDFiumRange>::iterator it = rect_range->begin();
2210 it != rect_range->end(); ++it) {
2211 pp::Rect rect;
2212 std::vector<pp::Rect> rects =
2213 (*it).GetScreenRects(offset_point, current_zoom_, current_rotation_);
gene 2015/01/08 18:27:57 nit: change "(*it)." to "it->"
Deepak 2015/01/09 02:55:21 Done.
2214 for (size_t j = 0; j < rects.size(); ++j)
2215 rect = rect.Union(rects[j]);
2216 rect_vector->push_back(rect);
2217 }
2218 }
2219
2189 void PDFiumEngine::UpdateTickMarks() { 2220 void PDFiumEngine::UpdateTickMarks() {
2190 std::vector<pp::Rect> tickmarks; 2221 std::vector<pp::Rect> tickmarks;
2191 for (size_t i = 0; i < find_results_.size(); ++i) { 2222 GetAllScreenRectsUnion(&find_results_, pp::Point(0, 0), &tickmarks);
2192 pp::Rect rect;
2193 // Always use an origin of 0,0 since scroll positions don't affect tickmark.
2194 std::vector<pp::Rect> rects = find_results_[i].GetScreenRects(
2195 pp::Point(0, 0), current_zoom_, current_rotation_);
2196 for (size_t j = 0; j < rects.size(); ++j)
2197 rect = rect.Union(rects[j]);
2198 tickmarks.push_back(rect);
2199 }
2200
2201 client_->UpdateTickMarks(tickmarks); 2223 client_->UpdateTickMarks(tickmarks);
2202 } 2224 }
2203 2225
2204 void PDFiumEngine::ZoomUpdated(double new_zoom_level) { 2226 void PDFiumEngine::ZoomUpdated(double new_zoom_level) {
2205 CancelPaints(); 2227 CancelPaints();
2206 2228
2207 current_zoom_ = new_zoom_level; 2229 current_zoom_ = new_zoom_level;
2208 2230
2209 CalculateVisiblePages(); 2231 CalculateVisiblePages();
2210 UpdateTickMarks(); 2232 UpdateTickMarks();
(...skipping 1678 matching lines...) Expand 10 before | Expand all | Expand 10 after
3889 double* height) { 3911 double* height) {
3890 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); 3912 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL);
3891 if (!doc) 3913 if (!doc)
3892 return false; 3914 return false;
3893 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 3915 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
3894 FPDF_CloseDocument(doc); 3916 FPDF_CloseDocument(doc);
3895 return success; 3917 return success;
3896 } 3918 }
3897 3919
3898 } // namespace chrome_pdf 3920 } // namespace chrome_pdf
OLDNEW
« 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