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

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
« no previous file with comments | « printing/page_setup.h ('k') | printing/page_setup_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/page_setup.cc
diff --git a/printing/page_setup.cc b/printing/page_setup.cc
index b870323e04cc3c7180faaf1e798de0d251818ddb..ad0156eda455dc7e56be1988a5e54d79b22bcdaf 100644
--- a/printing/page_setup.cc
+++ b/printing/page_setup.cc
@@ -19,6 +19,14 @@ PageMargins::PageMargins()
bottom(0) {
}
+void PageMargins::Rotate() {
+ int temp_right = right;
+ right = bottom;
+ bottom = left;
+ left = top;
+ top = temp_right;
+}
+
void PageMargins::Clear() {
header = 0;
footer = 0;
@@ -50,6 +58,7 @@ void PageSetup::Clear() {
content_area_.SetRect(0, 0, 0, 0);
effective_margins_.Clear();
text_height_ = 0;
+ forced_margins_ = false;
}
bool PageSetup::Equals(const PageSetup& rhs) const {
@@ -76,19 +85,17 @@ void PageSetup::Init(const gfx::Size& physical_size,
printable_area_ = printable_area;
text_height_ = text_height;
- CalculateSizesWithinRect(printable_area_, text_height_);
+ SetRequestedMarginsAndCalculateSizes(requested_margins_);
}
void PageSetup::SetRequestedMargins(const PageMargins& requested_margins) {
- requested_margins_ = requested_margins;
- if (printable_area_.width() && printable_area_.height())
- CalculateSizesWithinRect(printable_area_, text_height_);
+ forced_margins_ = false;
+ SetRequestedMarginsAndCalculateSizes(requested_margins);
}
void PageSetup::ForceRequestedMargins(const PageMargins& requested_margins) {
- requested_margins_ = requested_margins;
- if (physical_size_.width() && physical_size_.height())
- CalculateSizesWithinRect(gfx::Rect(physical_size_), 0);
+ forced_margins_ = true;
+ SetRequestedMarginsAndCalculateSizes(requested_margins);
}
void PageSetup::FlipOrientation() {
@@ -100,10 +107,22 @@ void PageSetup::FlipOrientation() {
new_y,
printable_area_.height(),
printable_area_.width());
+ requested_margins_.Rotate();
Init(new_size, new_printable_area, text_height_);
}
}
+void PageSetup::SetRequestedMarginsAndCalculateSizes(
+ const PageMargins& requested_margins) {
+ requested_margins_ = requested_margins;
+ if (physical_size_.width() && physical_size_.height()) {
+ if (forced_margins_)
+ CalculateSizesWithinRect(gfx::Rect(physical_size_), 0);
+ else
+ CalculateSizesWithinRect(printable_area_, text_height_);
+ }
+}
+
void PageSetup::CalculateSizesWithinRect(const gfx::Rect& bounds,
int text_height) {
// Calculate the effective margins. The tricky part.
« no previous file with comments | « printing/page_setup.h ('k') | printing/page_setup_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698