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

Unified Diff: printing/page_setup.cc

Issue 8351063: PrintPreview: [LINUX] Update the margin values after flipping the paper orientation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 1 month 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: printing/page_setup.cc
diff --git a/printing/page_setup.cc b/printing/page_setup.cc
index b870323e04cc3c7180faaf1e798de0d251818ddb..c2a0b5a84f6fd62a28b204613bda88bdf1962392 100644
--- a/printing/page_setup.cc
+++ b/printing/page_setup.cc
@@ -19,6 +19,22 @@ PageMargins::PageMargins()
bottom(0) {
}
+PageMargins::PageMargins(const PageMargins& margins, bool rotate_margins) {
+ header = margins.header;
+ footer = margins.footer;
+ if (rotate_margins) {
+ top = margins.right;
+ left = margins.top;
+ bottom = margins.left;
+ right = margins.bottom;
+ } else {
+ top = margins.top;
+ left = margins.left;
+ bottom = margins.bottom;
+ right = margins.right;
+ }
+}
+
void PageMargins::Clear() {
header = 0;
footer = 0;
@@ -37,7 +53,7 @@ bool PageMargins::Equals(const PageMargins& rhs) const {
bottom == rhs.bottom;
}
-PageSetup::PageSetup() {
+PageSetup::PageSetup() : has_forced_margins_value(false) {
Clear();
}
@@ -81,12 +97,14 @@ void PageSetup::Init(const gfx::Size& physical_size,
void PageSetup::SetRequestedMargins(const PageMargins& requested_margins) {
requested_margins_ = requested_margins;
+ has_forced_margins_value = false;
if (printable_area_.width() && printable_area_.height())
CalculateSizesWithinRect(printable_area_, text_height_);
}
void PageSetup::ForceRequestedMargins(const PageMargins& requested_margins) {
requested_margins_ = requested_margins;
+ has_forced_margins_value = true;
if (physical_size_.width() && physical_size_.height())
CalculateSizesWithinRect(gfx::Rect(physical_size_), 0);
}
@@ -101,6 +119,11 @@ void PageSetup::FlipOrientation() {
printable_area_.height(),
printable_area_.width());
Init(new_size, new_printable_area, text_height_);
+ PageMargins new_requested_margins(requested_margins_, true);
+ if (has_forced_margins_value)
vandebo (ex-Chrome) 2011/11/02 20:26:03 With the addition of has_forced_margins_value, I t
kmadhusu 2011/11/02 23:15:03 Done.
+ ForceRequestedMargins(new_requested_margins);
+ else
+ SetRequestedMargins(new_requested_margins);
}
}

Powered by Google App Engine
This is Rietveld 408576698