OLD | NEW |
---|---|
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 Loading... | |
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 (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.
| |
846 url_copy = url_copy.substr(0, url_copy.length() - 1); | |
847 // if '#' is already present in |url_| then remove old tag and add new | |
848 // |url_copy| tag. | |
849 std::size_t found_idx = url_.find('#'); | |
850 if (found_idx != std::string::npos) | |
851 url_copy = url_.substr(0, found_idx) + url_copy; | |
852 else | |
853 url_copy = url_ + url_copy; | |
854 | |
855 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
| |
856 found_idx = url_copy.find('#'); | |
857 if (found_idx != std::string::npos) { | |
858 int page_number = | |
859 engine_->GetNamedDestinationPage(url_copy.substr(found_idx + 1)); | |
860 if (page_number >= 0) | |
861 ScrollToPage(page_number); | |
862 } | |
863 } | |
846 } | 864 } |
847 // If there's no scheme, add http. | 865 // If there's no scheme, add http. |
848 if (url_copy.find("://") == std::string::npos && | 866 if (url_copy.find("://") == std::string::npos && |
849 url_copy.find("mailto:") == std::string::npos) { | 867 url_copy.find("mailto:") == std::string::npos) { |
850 url_copy = std::string("http://") + url_copy; | 868 url_copy = std::string("http://") + url_copy; |
851 } | 869 } |
852 // Make sure |url_copy| starts with a valid scheme. | 870 // Make sure |url_copy| starts with a valid scheme. |
853 if (url_copy.find("http://") != 0 && | 871 if (url_copy.find("http://") != 0 && |
854 url_copy.find("https://") != 0 && | 872 url_copy.find("https://") != 0 && |
855 url_copy.find("ftp://") != 0 && | 873 url_copy.find("ftp://") != 0 && |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1382 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( | 1400 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( |
1383 const pp::FloatPoint& scroll_offset) { | 1401 const pp::FloatPoint& scroll_offset) { |
1384 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1402 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); | 1403 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(); | 1404 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); | 1405 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); |
1388 return pp::FloatPoint(x, y); | 1406 return pp::FloatPoint(x, y); |
1389 } | 1407 } |
1390 | 1408 |
1391 } // namespace chrome_pdf | 1409 } // namespace chrome_pdf |
OLD | NEW |