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

Side by Side Diff: pdf/out_of_process_instance.cc

Issue 830433002: Navigation to relative fragments does not work correctly for OOP pdf. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing Reviewer's 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 | « no previous file | 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/out_of_process_instance.h" 5 #include "pdf/out_of_process_instance.h"
6 6
7 #include <algorithm> // for min/max() 7 #include <algorithm> // for min/max()
8 #define _USE_MATH_DEFINES // for M_PI 8 #define _USE_MATH_DEFINES // for M_PI
9 #include <cmath> // for log() and pow() 9 #include <cmath> // for log() and pow()
10 #include <math.h> 10 #include <math.h>
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 bool open_in_new_tab) { 835 bool open_in_new_tab) {
836 std::string url_copy(url); 836 std::string url_copy(url);
837 837
838 // Empty |url_copy| is ok, and will effectively be a reload. 838 // Empty |url_copy| is ok, and will effectively be a reload.
839 // Skip the code below so an empty URL does not turn into "http://", which 839 // Skip the code below so an empty URL does not turn into "http://", which
840 // will cause GURL to fail a DCHECK. 840 // will cause GURL to fail a DCHECK.
841 if (!url_copy.empty()) { 841 if (!url_copy.empty()) {
842 // If |url_copy| starts with '#', then it's for the same URL with a 842 // If |url_copy| starts with '#', then it's for the same URL with a
843 // different URL fragment. 843 // different URL fragment.
844 if (url_copy[0] == '#') { 844 if (url_copy[0] == '#') {
845 url_copy = url_ + url_copy; 845 // if '#' is already present in |url_| then remove old tag and add new
846 // |url_copy| tag.
847 std::size_t found_idx = url_.find('#');
848 if (found_idx != std::string::npos)
849 url_copy = url_.substr(0, found_idx) + url_copy;
850 else
851 url_copy = url_ + url_copy;
852
853 if (!open_in_new_tab) {
854 found_idx = url_copy.find('#');
Lei Zhang 2015/01/07 23:08:43 There's some weird problems with OOP PDF. Without
855 if (found_idx != std::string::npos) {
856 int page_number =
857 engine_->GetNamedDestinationPage(url_copy.substr(found_idx + 1));
858 if (page_number >= 0)
859 ScrollToPage(page_number);
860 }
861 }
846 } 862 }
847 // If there's no scheme, add http. 863 // If there's no scheme, add http.
848 if (url_copy.find("://") == std::string::npos && 864 if (url_copy.find("://") == std::string::npos &&
849 url_copy.find("mailto:") == std::string::npos) { 865 url_copy.find("mailto:") == std::string::npos) {
850 url_copy = std::string("http://") + url_copy; 866 url_copy = std::string("http://") + url_copy;
851 } 867 }
852 // Make sure |url_copy| starts with a valid scheme. 868 // Make sure |url_copy| starts with a valid scheme.
853 if (url_copy.find("http://") != 0 && 869 if (url_copy.find("http://") != 0 &&
854 url_copy.find("https://") != 0 && 870 url_copy.find("https://") != 0 &&
855 url_copy.find("ftp://") != 0 && 871 url_copy.find("ftp://") != 0 &&
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( 1398 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument(
1383 const pp::FloatPoint& scroll_offset) { 1399 const pp::FloatPoint& scroll_offset) {
1384 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); 1400 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width();
1385 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); 1401 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f);
1386 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); 1402 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height();
1387 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); 1403 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f);
1388 return pp::FloatPoint(x, y); 1404 return pp::FloatPoint(x, y);
1389 } 1405 }
1390 1406
1391 } // namespace chrome_pdf 1407 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698