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

Unified Diff: chrome/browser/resources/pdf/navigator.js

Issue 918953002: Fix for PDFs with lots of named destinations take a long time to load. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing nit Created 5 years, 10 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
Index: chrome/browser/resources/pdf/navigator.js
diff --git a/chrome/browser/resources/pdf/navigator.js b/chrome/browser/resources/pdf/navigator.js
index 57c15d4d26c47c983f83a839c766cb79d22f9dfe..52b93207a509f261a4b0cb2a206338c495a5f8a9 100644
--- a/chrome/browser/resources/pdf/navigator.js
+++ b/chrome/browser/resources/pdf/navigator.js
@@ -71,15 +71,27 @@ Navigator.prototype = {
return;
}
- if (newTab) {
+ if (newTab)
this.navigateInNewTabCallback_(url);
- } else {
- var pageNumber =
- this.paramsParser_.getViewportFromUrlParams(url).page;
- if (pageNumber != undefined)
- this.viewport_.goToPage(pageNumber);
- else
- this.navigateInCurrentTabCallback_(url);
- }
+ else
+ this.onViewportReceived_(url);
raymes 2015/02/16 22:44:04 This isn't what I meant. Please keep this the same
Deepak 2015/02/17 07:12:12 Done.
+ },
+
+ /**
+ * @private
+ * Function to decide weather to scroll the page to corresponding named
+ * destination or open the url in the current tab.
+ * param {string} url The new url for name destination or opening it in
+ * current tab.
+ */
+ onViewportReceived_: function(url) {
+ this.paramsParser_.getViewportFromUrlParams(
+ url, function(viewportPosition) {
+ var pageNumber = viewportPosition.page;
+ if (pageNumber != undefined)
+ this.viewport_.goToPage(pageNumber);
+ else
+ this.navigateInCurrentTabCallback_(url);
+ }.bind(this));
}
};

Powered by Google App Engine
This is Rietveld 408576698