summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authoryuzo@chromium.org <yuzo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-23 01:01:34 +0000
committeryuzo@chromium.org <yuzo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-23 01:01:34 +0000
commitb95b915d8a831681ee4f7219152f2c00e5cd93cd (patch)
tree68406add013c43ffcb47f550ee64dd9f8899fdb9 /chrome/renderer
parent102e27c64d9deae4c32f346214fd7c2bddaa9fb3 (diff)
downloadchromium_src-b95b915d8a831681ee4f7219152f2c00e5cd93cd.zip
chromium_src-b95b915d8a831681ee4f7219152f2c00e5cd93cd.tar.gz
chromium_src-b95b915d8a831681ee4f7219152f2c00e5cd93cd.tar.bz2
Fix for Issue 73274: Printing causes view to scroll
Save and restore scroll offset when printing a page. This patch is applicable only after the patch for https://bugs.webkit.org/show_bug.cgi?id=54632 has been landed. This patch doesn't completely fix https://bugs.webkit.org/show_bug.cgi?id=52552 but the remaining issue is relatively minor. BUG=73274 TEST= Open a web page, scroll to the bottom, print, and observe the scroll position is not changed. See http://code.google.com/p/chromium/issues/detail?id=73274 Review URL: http://codereview.chromium.org/6539011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75689 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/print_web_view_helper.cc4
-rw-r--r--chrome/renderer/print_web_view_helper.h1
2 files changed, 5 insertions, 0 deletions
diff --git a/chrome/renderer/print_web_view_helper.cc b/chrome/renderer/print_web_view_helper.cc
index 518529d..5ca14e6 100644
--- a/chrome/renderer/print_web_view_helper.cc
+++ b/chrome/renderer/print_web_view_helper.cc
@@ -82,6 +82,8 @@ PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint(
print_layout_size.set_height(static_cast<int>(
static_cast<double>(print_layout_size.height()) * 1.25));
+ if (WebFrame* web_frame = web_view_->mainFrame())
+ prev_scroll_offset_ = web_frame->scrollOffset();
prev_view_size_ = web_view->size();
web_view->resize(print_layout_size);
@@ -97,6 +99,8 @@ PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint(
PrepareFrameAndViewForPrint::~PrepareFrameAndViewForPrint() {
frame_->printEnd();
web_view_->resize(prev_view_size_);
+ if (WebFrame* web_frame = web_view_->mainFrame())
+ web_frame->setScrollOffset(prev_scroll_offset_);
}
diff --git a/chrome/renderer/print_web_view_helper.h b/chrome/renderer/print_web_view_helper.h
index 5c7afcc..dfe3e92 100644
--- a/chrome/renderer/print_web_view_helper.h
+++ b/chrome/renderer/print_web_view_helper.h
@@ -60,6 +60,7 @@ class PrepareFrameAndViewForPrint {
WebKit::WebView* web_view_;
gfx::Size print_canvas_size_;
gfx::Size prev_view_size_;
+ gfx::Size prev_scroll_offset_;
int expected_pages_count_;
bool use_browser_overlays_;