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

Unified Diff: pdf/instance.cc

Issue 335993006: PDF: Fix navigation for links that are just relative fragments. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 6 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 | « no previous file | pdf/out_of_process_instance.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/instance.cc
===================================================================
--- pdf/instance.cc (revision 280032)
+++ pdf/instance.cc (working copy)
@@ -1176,15 +1176,29 @@
// Skip the code below so an empty URL does not turn into "http://", which
// will cause GURL to fail a DCHECK.
if (!url_copy.empty()) {
+ // If |url_copy| starts with '#', then it's for the same URL with a
+ // different URL fragment.
+ if (url_copy[0] == '#') {
+ url_copy = url_ + url_copy;
+ // Changing the href does not actually do anything when navigating in the
+ // same tab, so do the actual page scroll here. Then fall through so the
+ // href gets updated.
+ if (!open_in_new_tab) {
+ int page_number = GetInitialPage(url_copy);
+ if (page_number >= 0)
+ ScrollToPage(page_number);
+ }
+ }
// If there's no scheme, add http.
if (url_copy.find("://") == std::string::npos &&
url_copy.find("mailto:") == std::string::npos) {
- url_copy = std::string("http://") + url_copy;
+ url_copy = "http://" + url_copy;
}
// Make sure |url_copy| starts with a valid scheme.
if (url_copy.find("http://") != 0 &&
url_copy.find("https://") != 0 &&
url_copy.find("ftp://") != 0 &&
+ url_copy.find("file://") != 0 &&
url_copy.find("mailto:") != 0) {
return;
}
@@ -1192,6 +1206,7 @@
if (url_copy == "http://" ||
url_copy == "https://" ||
url_copy == "ftp://" ||
+ url_copy == "file://" ||
url_copy == "mailto:") {
return;
}
« no previous file with comments | « no previous file | pdf/out_of_process_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698