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

Unified 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: Changing code for OOP case. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/out_of_process_instance.cc
diff --git a/pdf/out_of_process_instance.cc b/pdf/out_of_process_instance.cc
index 59b04394419410bc1eda3518839f2323169bbe94..c6358c182bd004d2808f377b9fa828bce5f521a3 100644
--- a/pdf/out_of_process_instance.cc
+++ b/pdf/out_of_process_instance.cc
@@ -842,7 +842,25 @@ void OutOfProcessInstance::NavigateTo(const std::string& url,
// 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;
+ if (url_copy[url_copy.length() - 1] == 0)
Lei Zhang 2015/01/06 02:13:16 This looks like a bug in PDFiumPage::GetLinkTarget
Deepak 2015/01/06 05:38:22 Yes, You are right, This is not required here.
+ url_copy = url_copy.substr(0, url_copy.length() - 1);
+ // if '#' is already present in |url_| then remove old tag and add new
+ // |url_copy| tag.
+ std::size_t found_idx = url_.find('#');
+ if (found_idx != std::string::npos)
+ url_copy = url_.substr(0, found_idx) + url_copy;
+ else
+ url_copy = url_ + url_copy;
+
+ if (!open_in_new_tab) {
Lei Zhang 2015/01/06 02:13:16 Why are we adding this block? Can't we just naviga
Deepak 2015/01/06 05:38:22 I need to add this block here as if I just pass ur
+ found_idx = url_copy.find('#');
+ if (found_idx != std::string::npos) {
+ int page_number =
+ engine_->GetNamedDestinationPage(url_copy.substr(found_idx + 1));
+ if (page_number >= 0)
+ ScrollToPage(page_number);
+ }
+ }
}
// If there's no scheme, add http.
if (url_copy.find("://") == std::string::npos &&
« 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